π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
fix
Smaug673938ca3e2cb64a
diff --git a/frontend/app/composables/useSidebar.ts b/frontend/app/composables/useSidebar.tsindex 63b88f31..942a8cd4 100644--- a/frontend/app/composables/useSidebar.ts+++ b/frontend/app/composables/useSidebar.ts@@ -3,39 +3,53 @@* Controls sidebar visibility, width, and content filtering*/-const { isMobile } = useDevice();-+// Module-level state (safe - these don't depend on Pinia)const isOpened = ref(false);const hasSidebar = ref(false);-const paneWidth = computed(() => (isMobile.value ? 340 : 390));const isResizing = ref(false);const workspaceId = ref<string | undefined>(undefined);const active_id = ref<string | null>(null);const toggleSidebar = () => (isOpened.value = !isOpened.value);-// Cache sidebar tree reference outside of computed to avoid recreating on each evaluation-const sidebarTreeRef = useSidebarTree();-const preferencesRef = usePreferences();+// Lazy-initialized references (only set once when useSidebar is first called)+let _sidebarTreeRef: ReturnType<typeof useSidebarTree> | null = null;+let _preferencesRef: ReturnType<typeof usePreferences> | null = null;+let _filtered: ComputedRef<Item[]> | null = null;+let _paneWidth: ComputedRef<number> | null = null;++export function useSidebar() {+ const { isMobile } = useDevice();-/** Filter tree items based on selected workspace and preferences */-const filtered = computed(() => {- const tree = sidebarTreeRef.tree;- const found = tree.value.find(i => i.id === workspaceId.value);+ // Lazy init: only create these once+ if (!_sidebarTreeRef) {+ _sidebarTreeRef = useSidebarTree();+ }+ if (!_preferencesRef) {+ _preferencesRef = usePreferences();+ }+ if (!_paneWidth) {+ _paneWidth = computed(() => (isMobile.value ? 340 : 390));+ }+ if (!_filtered) {+ /** Filter tree items based on selected workspace and preferences */+ _filtered = computed(() => {+ const tree = _sidebarTreeRef!.tree;+ const found = tree.value.find(i => i.id === workspaceId.value);- if (found) return found.childrens || [];- if (workspaceId.value === 'shared') return tree.value.filter(i => i.data && i.data.shared);- if (!preferencesRef.get('displayUncategorizedResources').value) return tree.value.filter(i => i.data && i.data.role != 4); // hide uncategorized- return tree.value;-});+ if (found) return found.childrens || [];+ if (workspaceId.value === 'shared') return tree.value.filter(i => i.data && i.data.shared);+ if (!_preferencesRef!.get('displayUncategorizedResources').value) return tree.value.filter(i => i.data && i.data.role != 4); // hide uncategorized+ return tree.value;+ });+ }-export function useSidebar() {return {- filtered,+ filtered: _filtered,toggleSidebar,isOpened,hasSidebar,- paneWidth,+ paneWidth: _paneWidth,isResizing,workspaceId,active_id,