Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Performances improvment

Smaug6739f03fb279d5bc
diff --git a/frontend/app/composables/useSidebar.ts b/frontend/app/composables/useSidebar.ts
index a83363fe..63b88f31 100644
--- a/frontend/app/composables/useSidebar.ts
+++ b/frontend/app/composables/useSidebar.ts
@@ -14,14 +14,18 @@ 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();
+
/** Filter tree items based on selected workspace and preferences */
const filtered = computed(() => {
- const { tree } = useSidebarTree();
+ 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 (!usePreferences().get('displayUncategorizedResources').value) return tree.value.filter(i => i.data && i.data.role != 4); // hide uncategorized
+ if (!preferencesRef.get('displayUncategorizedResources').value) return tree.value.filter(i => i.data && i.data.role != 4); // hide uncategorized
return tree.value;
});
diff --git a/frontend/app/pages/dashboard.vue b/frontend/app/pages/dashboard.vue
index 8aabc671..82ae213e 100644
--- a/frontend/app/pages/dashboard.vue
+++ b/frontend/app/pages/dashboard.vue
@@ -13,6 +13,11 @@
</template>
<script setup lang="ts">
definePageMeta({ breadcrumb: 'Home' });
-useNodesStore().init();
-useUserStore().fetch();
+
+// Initialize stores in parallel - don't block rendering but ensure they start immediately
+const nodesStore = useNodesStore();
+const userStore = useUserStore();
+
+nodesStore.init();
+userStore.fetch();
</script>
diff --git a/frontend/app/stores/nodes.store.ts b/frontend/app/stores/nodes.store.ts
index ab067dc4..1f8b8f1d 100644
--- a/frontend/app/stores/nodes.store.ts
+++ b/frontend/app/stores/nodes.store.ts
@@ -181,11 +181,11 @@ export const useNodesStore = defineStore('nodes', {
},
},
actions: {
- init() {
+ async init() {
console.log('[store/nodes] Initializing store');
this.clear();
- this.fetch();
- this.fetchShared();
+ // Fetch both in parallel for better performance
+ await Promise.all([this.fetch(), this.fetchShared()]);
},
recomputeTags() {
const tags = new Set<string>();
@@ -239,7 +239,6 @@ export const useNodesStore = defineStore('nodes', {
},
async fetchShared(): Promise<Collection<string, Node>> {
console.log(`[store/nodes] Fetching shared nodes`);
- if (this.nodes.size) return this.nodes;
const request = await makeRequest(`nodes/shared/@me`, 'GET', {});
if (request.status === 'success') {
for (const node of request.result as DB_Node[]) {