mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02: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:
parent
0a344731c8
commit
42523bbfc9
7 changed files with 32 additions and 22 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue