1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-04 21:15:22 +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:
Michael Genson 2024-03-12 17:36:30 -05:00 committed by GitHub
parent 0a344731c8
commit 42523bbfc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 32 additions and 22 deletions

View file

@ -4,6 +4,7 @@ import { MultiPurposeLabelOut } from "~/lib/api/types/labels";
import { useUserApi } from "~/composables/api";
let labelStore: Ref<MultiPurposeLabelOut[] | null> = ref([]);
const storeLoading = ref(false);
export function useLabelData() {
const data = reactive({
@ -28,7 +29,7 @@ export function useLabelData() {
export function useLabelStore() {
const api = useUserApi();
const loading = ref(false);
const loading = storeLoading;
const actions = {
...useStoreActions<MultiPurposeLabelOut>(api.multiPurposeLabels, labelStore, loading),
@ -37,7 +38,7 @@ export function useLabelStore() {
},
};
if (!labelStore.value || labelStore.value?.length === 0) {
if (!loading.value && (!labelStore.value || labelStore.value?.length === 0)) {
labelStore = actions.getAll();
}