π 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 document sort and doc update partial
Smaug6739872c02225471
diff --git a/backend/services/document.service.go b/backend/services/document.service.goindex 48867f5d..e8aa1f70 100644--- a/backend/services/document.service.go+++ b/backend/services/document.service.go@@ -21,7 +21,7 @@ func NewDocumentService(db *sql.DB) DocumentService {func (s *Service) GetAllDocuments(userId types.Snowflake) ([]*models.Document, error) {var documents = make([]*models.Document, 0)- rows, err := s.db.Query("SELECT id, name, description, tags, pinned, category, parent_id, accessibility, author_id, created_timestamp, updated_timestamp FROM documents WHERE author_id = ? ORDER BY name", userId)+ rows, err := s.db.Query("SELECT id, name, description, tags, pinned, category, parent_id, accessibility, author_id, created_timestamp, updated_timestamp FROM documents WHERE author_id = ? ORDER BY pinned DESC, name", userId)if err != nil {return nil, err}diff --git a/frontend/app/composables/useSidebarTree.ts b/frontend/app/composables/useSidebarTree.tsindex 0a33f69f..bfb41705 100644--- a/frontend/app/composables/useSidebarTree.ts+++ b/frontend/app/composables/useSidebarTree.ts@@ -25,15 +25,17 @@ export function useSidebarTree() {);const documents = computed<Item[]>(() =>- documentsStore.documents.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)),- })),+ 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[]>(() => {if (!preferencesStore.get('hideSidebarRessources'))diff --git a/frontend/app/stores/documents.store.ts b/frontend/app/stores/documents.store.tsindex 50604d80..c63b3ce7 100644--- a/frontend/app/stores/documents.store.ts+++ b/frontend/app/stores/documents.store.ts@@ -68,6 +68,12 @@ export const useDocumentsStore = defineStore('documents', {},update(doc: Document) {return new Promise(async (resolve, reject) => {+ if (doc.partial) {+ console.log('[store/documents] Document is partial, cannot update it directly.');+ const fullDoc = await this.fetch({ id: doc.id });+ if (!fullDoc) return reject('Document not found');+ doc = { ...doc, content_markdown: fullDoc.content_markdown, content_html: fullDoc.content_html, partial: false }; // Merge with full document data+ }const request = await makeRequest(`documents/${doc.id}`, 'PUT', doc);if (request.status == 'success') resolve((this.documents = this.documents.map(d => (d.id == doc.id ? doc : d))));else reject(request.message);