From c759868f5095e7b4f5eb9cc3f7d34ca76073ef7d Mon Sep 17 00:00:00 2001 From: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com> Date: Mon, 5 Feb 2024 11:39:19 +0000 Subject: [PATCH] getAll if array is empty or non existant --- frontend/composables/store/use-food-store.ts | 4 ++-- frontend/composables/store/use-label-store.ts | 4 ++-- frontend/composables/store/use-unit-store.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/composables/store/use-food-store.ts b/frontend/composables/store/use-food-store.ts index b7c3953e3d2..37038e7259d 100644 --- a/frontend/composables/store/use-food-store.ts +++ b/frontend/composables/store/use-food-store.ts @@ -43,7 +43,7 @@ export const usePublicFoodStore = function (groupSlug: string) { }, }; - if (!foodStore.value) { + if (!foodStore.value || foodStore.value.length === 0) { foodStore = actions.getAll(); } @@ -61,7 +61,7 @@ export const useFoodStore = function () { }, }; - if (!foodStore) { + if (!foodStore.value || foodStore.value.length === 0) { foodStore = actions.getAll(); } diff --git a/frontend/composables/store/use-label-store.ts b/frontend/composables/store/use-label-store.ts index 37fc48552fe..77da62f07f9 100644 --- a/frontend/composables/store/use-label-store.ts +++ b/frontend/composables/store/use-label-store.ts @@ -33,11 +33,11 @@ export function useLabelStore() { const actions = { ...useStoreActions(api.multiPurposeLabels, labelStore, loading), flushStore() { - labelStore.value =[]; + labelStore.value = []; }, }; - if (!labelStore.value) { + if (!labelStore.value || labelStore.value?.length === 0) { labelStore = actions.getAll(); } diff --git a/frontend/composables/store/use-unit-store.ts b/frontend/composables/store/use-unit-store.ts index b2af6e9057d..bf4c3cf3216 100644 --- a/frontend/composables/store/use-unit-store.ts +++ b/frontend/composables/store/use-unit-store.ts @@ -44,7 +44,7 @@ export const useUnitStore = function () { }, }; - if (!unitStore.value) { + if (!unitStore.value || unitStore.value.length === 0) { unitStore = actions.getAll(); }