mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
create use-cookbook-store and switch to that for the sidebar
This commit is contained in:
parent
181aebf424
commit
395545dce5
2 changed files with 19 additions and 2 deletions
|
@ -119,8 +119,8 @@
|
|||
import { useLoggedInState } from "~/composables/use-logged-in-state";
|
||||
import type { SideBarLink } from "~/types/application-types";
|
||||
import { useAppInfo } from "~/composables/api";
|
||||
import { useCookbooks, usePublicCookbooks } from "~/composables/use-group-cookbooks";
|
||||
import { useCookbookPreferences } from "~/composables/use-users/preferences";
|
||||
import { useCookbookStore, usePublicCookbookStore } from "~/composables/store/use-cookbook-store";
|
||||
import { useHouseholdStore, usePublicHouseholdStore } from "~/composables/store/use-household-store";
|
||||
import { useToggleDarkMode } from "~/composables/use-utils";
|
||||
import type { ReadCookBook } from "~/lib/api/types/cookbook";
|
||||
|
@ -136,9 +136,9 @@ export default defineNuxtComponent({
|
|||
const isAdmin = computed(() => $auth.user.value?.admin);
|
||||
const route = useRoute();
|
||||
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
|
||||
const { cookbooks } = isOwnGroup.value ? useCookbooks() : usePublicCookbooks(groupSlug.value || "");
|
||||
|
||||
const cookbookPreferences = useCookbookPreferences();
|
||||
const { store: cookbooks } = isOwnGroup.value ? useCookbookStore() : usePublicCookbookStore(groupSlug.value || "");
|
||||
const { store: households } = isOwnGroup.value ? useHouseholdStore() : usePublicHouseholdStore(groupSlug.value || "");
|
||||
|
||||
const householdsById = computed(() => {
|
||||
|
|
17
frontend/composables/store/use-cookbook-store.ts
Normal file
17
frontend/composables/store/use-cookbook-store.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { useReadOnlyStore } from "../partials/use-store-factory";
|
||||
import { usePublicExploreApi, useUserApi } from "~/composables/api";
|
||||
import type { RecipeCookBook } from "~/lib/api/types/cookbook";
|
||||
|
||||
const store: Ref<RecipeCookBook[]> = ref([]);
|
||||
const loading = ref(false);
|
||||
const publicLoading = ref(false);
|
||||
|
||||
export const useCookbookStore = function () {
|
||||
const api = useUserApi();
|
||||
return useReadOnlyStore<RecipeCookBook>(store, loading, api.cookbooks);
|
||||
};
|
||||
|
||||
export const usePublicCookbookStore = function (groupSlug: string) {
|
||||
const api = usePublicExploreApi(groupSlug).explore;
|
||||
return useReadOnlyStore<RecipeCookBook>(store, publicLoading, api.cookbooks);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue