mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-05-13 21:37:42 -04:00
fix: Infinite API request loop on empty stores (#7613)
This commit is contained in:
@@ -5,12 +5,16 @@ import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
||||
|
||||
const store: Ref<RecipeCategory[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
const initialized = ref(false);
|
||||
const publicLoading = ref(false);
|
||||
const publicInitialized = ref(false);
|
||||
|
||||
export function resetCategoryStore() {
|
||||
store.value = [];
|
||||
loading.value = false;
|
||||
initialized.value = false;
|
||||
publicLoading.value = false;
|
||||
publicInitialized.value = false;
|
||||
}
|
||||
|
||||
export const useCategoryData = function () {
|
||||
@@ -23,10 +27,10 @@ export const useCategoryData = function () {
|
||||
|
||||
export const useCategoryStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<RecipeCategory>("category", store, loading, api.categories);
|
||||
return useStore<RecipeCategory>("category", store, loading, initialized, api.categories);
|
||||
};
|
||||
|
||||
export const usePublicCategoryStore = function (groupSlug: string, i18n?: Composer) {
|
||||
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
||||
return useReadOnlyStore<RecipeCategory>("category", store, publicLoading, api.categories);
|
||||
return useReadOnlyStore<RecipeCategory>("category", store, publicLoading, publicInitialized, api.categories);
|
||||
};
|
||||
|
||||
@@ -5,17 +5,21 @@ import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
||||
|
||||
const cookbooks: Ref<ReadCookBook[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
const initialized = ref(false);
|
||||
const publicLoading = ref(false);
|
||||
const publicInitialized = ref(false);
|
||||
|
||||
export function resetCookbookStore() {
|
||||
cookbooks.value = [];
|
||||
loading.value = false;
|
||||
initialized.value = false;
|
||||
publicLoading.value = false;
|
||||
publicInitialized.value = false;
|
||||
}
|
||||
|
||||
export const useCookbookStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
const store = useStore<ReadCookBook>("cookbook", cookbooks, loading, api.cookbooks);
|
||||
const store = useStore<ReadCookBook>("cookbook", cookbooks, loading, initialized, api.cookbooks);
|
||||
|
||||
const updateAll = async function (updateData: UpdateCookBook[]) {
|
||||
loading.value = true;
|
||||
@@ -31,5 +35,5 @@ export const useCookbookStore = function (i18n?: Composer) {
|
||||
|
||||
export const usePublicCookbookStore = function (groupSlug: string, i18n?: Composer) {
|
||||
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
||||
return useReadOnlyStore<ReadCookBook>("cookbook", cookbooks, publicLoading, api.cookbooks);
|
||||
return useReadOnlyStore<ReadCookBook>("cookbook", cookbooks, publicLoading, publicInitialized, api.cookbooks);
|
||||
};
|
||||
|
||||
@@ -5,12 +5,16 @@ import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
||||
|
||||
const store: Ref<IngredientFood[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
const initialized = ref(false);
|
||||
const publicLoading = ref(false);
|
||||
const publicInitialized = ref(false);
|
||||
|
||||
export function resetFoodStore() {
|
||||
store.value = [];
|
||||
loading.value = false;
|
||||
initialized.value = false;
|
||||
publicLoading.value = false;
|
||||
publicInitialized.value = false;
|
||||
}
|
||||
|
||||
export const useFoodData = function () {
|
||||
@@ -24,10 +28,10 @@ export const useFoodData = function () {
|
||||
|
||||
export const useFoodStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<IngredientFood>("food", store, loading, api.foods);
|
||||
return useStore<IngredientFood>("food", store, loading, initialized, api.foods);
|
||||
};
|
||||
|
||||
export const usePublicFoodStore = function (groupSlug: string, i18n?: Composer) {
|
||||
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
||||
return useReadOnlyStore<IngredientFood>("food", store, publicLoading, api.foods);
|
||||
return useReadOnlyStore<IngredientFood>("food", store, publicLoading, publicInitialized, api.foods);
|
||||
};
|
||||
|
||||
@@ -5,20 +5,24 @@ import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
||||
|
||||
const store: Ref<HouseholdSummary[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
const initialized = ref(false);
|
||||
const publicLoading = ref(false);
|
||||
const publicInitialized = ref(false);
|
||||
|
||||
export function resetHouseholdStore() {
|
||||
store.value = [];
|
||||
loading.value = false;
|
||||
initialized.value = false;
|
||||
publicLoading.value = false;
|
||||
publicInitialized.value = false;
|
||||
}
|
||||
|
||||
export const useHouseholdStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useReadOnlyStore<HouseholdSummary>("household", store, loading, api.households);
|
||||
return useReadOnlyStore<HouseholdSummary>("household", store, loading, initialized, api.households);
|
||||
};
|
||||
|
||||
export const usePublicHouseholdStore = function (groupSlug: string, i18n?: Composer) {
|
||||
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
||||
return useReadOnlyStore<HouseholdSummary>("household-public", store, publicLoading, api.households);
|
||||
return useReadOnlyStore<HouseholdSummary>("household-public", store, publicLoading, publicInitialized, api.households);
|
||||
};
|
||||
|
||||
@@ -5,10 +5,12 @@ import { useUserApi } from "~/composables/api";
|
||||
|
||||
const store: Ref<MultiPurposeLabelOut[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
const initialized = ref(false);
|
||||
|
||||
export function resetLabelStore() {
|
||||
store.value = [];
|
||||
loading.value = false;
|
||||
initialized.value = false;
|
||||
}
|
||||
|
||||
export const useLabelData = function () {
|
||||
@@ -22,5 +24,5 @@ export const useLabelData = function () {
|
||||
|
||||
export const useLabelStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<MultiPurposeLabelOut>("label", store, loading, api.multiPurposeLabels);
|
||||
return useStore<MultiPurposeLabelOut>("label", store, loading, initialized, api.multiPurposeLabels);
|
||||
};
|
||||
|
||||
@@ -5,12 +5,16 @@ import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
||||
|
||||
const store: Ref<RecipeTag[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
const initialized = ref(false);
|
||||
const publicLoading = ref(false);
|
||||
const publicInitialized = ref(false);
|
||||
|
||||
export function resetTagStore() {
|
||||
store.value = [];
|
||||
loading.value = false;
|
||||
initialized.value = false;
|
||||
publicLoading.value = false;
|
||||
publicInitialized.value = false;
|
||||
}
|
||||
|
||||
export const useTagData = function () {
|
||||
@@ -23,10 +27,10 @@ export const useTagData = function () {
|
||||
|
||||
export const useTagStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<RecipeTag>("tag", store, loading, api.tags);
|
||||
return useStore<RecipeTag>("tag", store, loading, initialized, api.tags);
|
||||
};
|
||||
|
||||
export const usePublicTagStore = function (groupSlug: string, i18n?: Composer) {
|
||||
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
||||
return useReadOnlyStore<RecipeTag>("tag", store, publicLoading, api.tags);
|
||||
return useReadOnlyStore<RecipeTag>("tag", store, publicLoading, publicInitialized, api.tags);
|
||||
};
|
||||
|
||||
@@ -9,12 +9,16 @@ interface RecipeToolWithOnHand extends RecipeTool {
|
||||
|
||||
const store: Ref<RecipeTool[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
const initialized = ref(false);
|
||||
const publicLoading = ref(false);
|
||||
const publicInitialized = ref(false);
|
||||
|
||||
export function resetToolStore() {
|
||||
store.value = [];
|
||||
loading.value = false;
|
||||
initialized.value = false;
|
||||
publicLoading.value = false;
|
||||
publicInitialized.value = false;
|
||||
}
|
||||
|
||||
export const useToolData = function () {
|
||||
@@ -29,10 +33,10 @@ export const useToolData = function () {
|
||||
|
||||
export const useToolStore = function (i18n?: Composer) {
|
||||
const api = useUserApi(i18n);
|
||||
return useStore<RecipeTool>("tool", store, loading, api.tools);
|
||||
return useStore<RecipeTool>("tool", store, loading, initialized, api.tools);
|
||||
};
|
||||
|
||||
export const usePublicToolStore = function (groupSlug: string, i18n?: Composer) {
|
||||
const api = usePublicExploreApi(groupSlug, i18n).explore;
|
||||
return useReadOnlyStore<RecipeTool>("tool", store, publicLoading, api.tools);
|
||||
return useReadOnlyStore<RecipeTool>("tool", store, publicLoading, publicInitialized, api.tools);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -6,10 +6,12 @@ import { BaseCRUDAPIReadOnly } from "~/lib/api/base/base-clients";
|
||||
|
||||
const store: Ref<UserSummary[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
const initialized = ref(false);
|
||||
|
||||
export function resetUserStore() {
|
||||
store.value = [];
|
||||
loading.value = false;
|
||||
initialized.value = false;
|
||||
}
|
||||
|
||||
class GroupUserAPIReadOnly extends BaseCRUDAPIReadOnly<UserSummary> {
|
||||
@@ -21,5 +23,5 @@ export const useUserStore = function (i18n?: Composer) {
|
||||
const requests = useRequests(i18n);
|
||||
const api = new GroupUserAPIReadOnly(requests);
|
||||
|
||||
return useReadOnlyStore<UserSummary>("user", store, loading, api, { orderBy: "full_name" });
|
||||
return useReadOnlyStore<UserSummary>("user", store, loading, initialized, api, { orderBy: "full_name" });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user