Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(collections/dashboard): not saving layout
Elian Doran2d6321b1d7fd
diff --git a/apps/client/src/widgets/collections/dashboard/index.tsx b/apps/client/src/widgets/collections/dashboard/index.tsxindex 374b454686..30cfdc5cc5 100644--- a/apps/client/src/widgets/collections/dashboard/index.tsx+++ b/apps/client/src/widgets/collections/dashboard/index.tsx@@ -116,12 +116,14 @@ export default function DashboardView({ note, noteIds, viewConfig, saveConfig, hconst container = containerRef.current;if (!grid || !container) return;+ let changed = false;grid.batchUpdate();try {// Drop engine nodes whose element Preact has already unmounted.for (const node of [ ...grid.engine.nodes ]) {if (node.el && !node.el.isConnected) {grid.removeWidget(node.el, false, false);+ changed = true;}}@@ -137,13 +139,18 @@ export default function DashboardView({ note, noteIds, viewConfig, saveConfig, hautoPosition: !saved});el.classList.add(INITIALIZED_CLASS);+ changed = true;}} finally {grid.batchUpdate(false);}- // Persist auto-assigned positions and prune entries of removed notes.- persistLayout(grid);+ // Persist auto-assigned positions and prune entries of removed notes — but only when+ // reconciliation actually touched the grid. Running on an empty grid (e.g. before the+ // notes have loaded on mount) would otherwise save an empty layout over the real one.+ if (changed) {+ persistLayout(grid);+ }}, [ notes ]);// React to external changes of the layout (e.g. the same dashboard open in another split