diff --git a/src/shared/stores/events/events-store.ts b/src/shared/stores/events/events-store.ts index 60ea9cc4..a0b13ffa 100644 --- a/src/shared/stores/events/events-store.ts +++ b/src/shared/stores/events/events-store.ts @@ -34,7 +34,7 @@ export const useEventsStore = defineStore("eventsStore", { projects: { available: [] as TProjects['data'], activeKey: null as string | null, - default: null as string | null, + defaultKey: null as string | null, } }), getters: { @@ -57,7 +57,9 @@ export const useEventsStore = defineStore("eventsStore", { return Object.entries(cachedIds).filter(([_, value]) => value.length > 0).map(([key]) => key as TEventsGroup) }, activeProjectKey: ({ projects }) => projects.activeKey, + activeProject: ({ projects }) => projects.available.find((proj) => proj.key === projects.activeKey) || projects.available[0], availableProjects: ({ projects }) => projects.available, + isMultipleProjects: ({ projects }) => (projects.available.length > 1), }, actions: { async initialize (): Promise { @@ -220,7 +222,7 @@ export const useEventsStore = defineStore("eventsStore", { removeStoredProject(); }, setDefaultProject(key: string) { - this.projects.default = key; + this.projects.defaultKey = key; } }, }); diff --git a/src/widgets/ui/layout-sidebar/layout-sidebar.vue b/src/widgets/ui/layout-sidebar/layout-sidebar.vue index 05e95490..bf373161 100644 --- a/src/widgets/ui/layout-sidebar/layout-sidebar.vue +++ b/src/widgets/ui/layout-sidebar/layout-sidebar.vue @@ -12,7 +12,6 @@ import { useEventsStore, } from "~/src/shared/stores"; import { useConnectionStore } from "~/src/shared/stores/connections"; -import type { TProjects } from "~/src/shared/types"; import { BadgeNumber, IconSvg } from "~/src/shared/ui"; import { version } from "../../../../package.json"; import { EVENTS_LINKS_MAP, EVENTS_NAV_ORDER } from "./constants"; @@ -20,7 +19,8 @@ import { EVENTS_LINKS_MAP, EVENTS_NAV_ORDER } from "./constants"; const { isConnectedWS } = storeToRefs(useConnectionStore()); const { isVisibleEventCounts, auth } = storeToRefs(useSettingsStore()); const eventsStore = useEventsStore(); -const { availableProjects, activeProjectKey } = storeToRefs(eventsStore); +const { availableProjects, isMultipleProjects, activeProject } = + storeToRefs(eventsStore); const profileStore = useProfileStore(); const { profile } = storeToRefs(profileStore); @@ -93,14 +93,6 @@ const toggleProjects = () => { isVisibleProjects.value = !isVisibleProjects.value; }; -const activeProject = computed(() => { - const project = availableProjects.value.find( - (p) => p.key === activeProjectKey.value, - ); - - return project as unknown as TProjects["data"][number]; -}); - const logout = () => { profileStore.removeToken(); const router = useRouter(); @@ -146,7 +138,7 @@ const generateRadialGradient = (input: string) => -