fix: Infinite API request loop on empty stores (#7613)

This commit is contained in:
Michael Genson
2026-05-12 12:25:48 -05:00
committed by GitHub
parent 703db2931f
commit af75c5f39d
12 changed files with 82 additions and 22 deletions

View File

@@ -5,10 +5,12 @@ import { useUserApi } from "~/composables/api";
const store: Ref<IngredientUnit[]> = ref([]);
const loading = ref(false);
const initialized = ref(false);
export function resetUnitStore() {
store.value = [];
loading.value = false;
initialized.value = false;
}
export const useUnitData = function () {
@@ -23,5 +25,5 @@ export const useUnitData = function () {
export const useUnitStore = function (i18n?: Composer) {
const api = useUserApi(i18n);
return useStore<IngredientUnit>("unit", store, loading, api.units);
return useStore<IngredientUnit>("unit", store, loading, initialized, api.units);
};