From fe047ace93fc49d4cd9bd71433501a8954bdaea7 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 29 Jan 2024 22:53:49 +0530 Subject: [PATCH] fix: moved isSidebarCollapsed value to globalStore --- frontend/src/components/Layouts/AppSidebar.vue | 8 ++++++-- frontend/src/stores/global.js | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Layouts/AppSidebar.vue b/frontend/src/components/Layouts/AppSidebar.vue index c7ed5b5b..10f9c859 100644 --- a/frontend/src/components/Layouts/AppSidebar.vue +++ b/frontend/src/components/Layouts/AppSidebar.vue @@ -94,12 +94,16 @@ import NotificationsIcon from '@/components/Icons/NotificationsIcon.vue' import SidebarLink from '@/components/SidebarLink.vue' import { viewsStore } from '@/stores/views' import { notificationsStore } from '@/stores/notifications' -import { useStorage } from '@vueuse/core' +import { globalStore } from '@/stores/global' import { computed } from 'vue' const { getPinnedViews, getPublicViews } = viewsStore() const { toggle: toggleNotificationPanel } = notificationsStore() -const isSidebarCollapsed = useStorage('sidebar_is_collapsed', false) + +const isSidebarCollapsed = computed({ + get: () => globalStore().isSidebarCollapsed, + set: (value) => globalStore().setIsSidebarCollapsed(value), +}) const links = [ { diff --git a/frontend/src/stores/global.js b/frontend/src/stores/global.js index 953493e8..d806d50a 100644 --- a/frontend/src/stores/global.js +++ b/frontend/src/stores/global.js @@ -1,3 +1,4 @@ +import { useStorage } from '@vueuse/core' import { defineStore } from 'pinia' import { getCurrentInstance, ref } from 'vue' @@ -6,6 +7,7 @@ export const globalStore = defineStore('crm-global', () => { const { $dialog } = app.appContext.config.globalProperties let twilioEnabled = ref(false) + let isSidebarCollapsed = useStorage('isSidebarCollapsed', false) let callMethod = () => {} function setTwilioEnabled(value) { @@ -20,9 +22,15 @@ export const globalStore = defineStore('crm-global', () => { callMethod(number) } + function setIsSidebarCollapsed(value) { + isSidebarCollapsed.value = value + } + return { $dialog, twilioEnabled, + isSidebarCollapsed, + setIsSidebarCollapsed, makeCall, setTwilioEnabled, setMakeCall,