mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-10-27 08:14:30 -04:00
fix: Only call store APIs once (#3306)
* move loading value to inside async function * share loading state and use it for throttling
This commit is contained in:
@@ -37,6 +37,7 @@ export function usePublicStoreActions<T extends BoundT>(
|
||||
loading.value = true;
|
||||
const allItems = useAsync(async () => {
|
||||
const { data } = await api.getAll(page, perPage, params);
|
||||
loading.value = false;
|
||||
|
||||
if (data && allRef) {
|
||||
allRef.value = data.items;
|
||||
@@ -49,7 +50,6 @@ export function usePublicStoreActions<T extends BoundT>(
|
||||
}
|
||||
}, useAsyncKey());
|
||||
|
||||
loading.value = false;
|
||||
return allItems;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ export function useStoreActions<T extends BoundT>(
|
||||
loading.value = true;
|
||||
const allItems = useAsync(async () => {
|
||||
const { data } = await api.getAll(page, perPage, params);
|
||||
loading.value = false;
|
||||
|
||||
if (data && allRef) {
|
||||
allRef.value = data.items;
|
||||
@@ -100,7 +101,6 @@ export function useStoreActions<T extends BoundT>(
|
||||
}
|
||||
}, useAsyncKey());
|
||||
|
||||
loading.value = false;
|
||||
return allItems;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user