π 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
Performances improvment: Wait for items ready before calculate
Smaug6739d4b9f026b255
diff --git a/frontend/app/composables/useSidebarTree.ts b/frontend/app/composables/useSidebarTree.tsindex e1bb26b2..afc7dc69 100644--- a/frontend/app/composables/useSidebarTree.ts+++ b/frontend/app/composables/useSidebarTree.ts@@ -9,33 +9,40 @@ export function useSidebarTree() {const preferencesStore = usePreferences();const { workspaceId } = useSidebar();+ // Wait for categories and documents to be fetched+ const isReady = computed(() => !categoriesStore.isFetching && !documentsStore.isFetching && !ressourcesStore.isFetching);+const categories = computed<Item<Category>[]>(() =>- categoriesStore.categories.map(cat => ({- id: cat.id,- parent_id: cat.parent_id || '',- label: cat.name,- route: `/dashboard/categories/${cat.id}`,- icon: cat.icon || 'folder',- data: cat,- show: ref(getCollapseState(cat.id)),- })),+ isReady.value+ ? categoriesStore.categories.map(cat => ({+ id: cat.id,+ parent_id: cat.parent_id || '',+ label: cat.name,+ route: `/dashboard/categories/${cat.id}`,+ icon: cat.icon || 'folder',+ data: cat,+ show: ref(getCollapseState(cat.id)),+ }))+ : [],);const documents = computed<Item<Document>[]>(() =>- documentsStore.documents- .sort((a, b) => b.pinned - a.pinned || a.name.localeCompare(b.name))- .map(doc => ({- id: doc.id,- parent_id: doc.parent_id || doc.category || '',- label: doc.name,- route: `/dashboard/docs/${doc.id}`,- icon: doc.accessibility == 1 ? 'file' : doc.accessibility == 2 ? 'draft' : 'archive',- data: doc,- show: ref(getCollapseState(doc.id)),- })),+ isReady.value+ ? documentsStore.documents+ .sort((a, b) => b.pinned - a.pinned || a.name.localeCompare(b.name))+ .map(doc => ({+ id: doc.id,+ parent_id: doc.parent_id || doc.category || '',+ label: doc.name,+ route: `/dashboard/docs/${doc.id}`,+ icon: doc.accessibility == 1 ? 'file' : doc.accessibility == 2 ? 'draft' : 'archive',+ data: doc,+ show: ref(getCollapseState(doc.id)),+ }))+ : [],);const ressources = computed<Item<Ressource>[]>(() => {- if (!preferencesStore.get('hideSidebarRessources'))+ if (!preferencesStore.get('hideSidebarRessources') && isReady.value)return ressourcesStore.getAll.filter(res => res.parent_id).map(res => ({diff --git a/frontend/app/stores/ressources.store.ts b/frontend/app/stores/ressources.store.tsindex f09b3780..9f7fbf67 100644--- a/frontend/app/stores/ressources.store.ts+++ b/frontend/app/stores/ressources.store.ts@@ -3,7 +3,8 @@ import type { DB_Ressource, Ressource } from './db_strustures';export const useRessourcesStore = defineStore('ressources', {state: () => ({- ressources: ref<Ressource[]>([]),+ ressources: [] as Ressource[],+ isFetching: false,}),getters: {getAll: state => state.ressources,@@ -12,8 +13,9 @@ export const useRessourcesStore = defineStore('ressources', {actions: {async fetch(): Promise<Ressource[]> {if (this.ressources.length > 0) return this.ressources;-+ this.isFetching = true;const request = await makeRequest(`ressources/@me`, 'GET', {});+ this.isFetching = false;if (request.status == 'success') {this.ressources = (request.result as DB_Ressource[]).map((d: DB_Ressource) => ({ ...d, type: 'ressource' })) as Ressource[];return this.ressources;