refactor: migrate graph canvas to use web worker for force layout computation

This commit is contained in:
2025-10-04 08:56:49 -04:00
parent a948d10512
commit e75fcd60cd
12 changed files with 869 additions and 186 deletions
@@ -141,10 +141,20 @@ export class GraphViewContainerV2Component {
return { nodes, links };
});
// Map note id -> raw content (for attachment extraction)
private noteContents = computed(() => {
const map = new Map<string, string>();
for (const n of this.vaultService.allNotes()) {
map.set(n.id, n.content || '');
}
return map;
});
// Apply all filters using selectors
private filteredData = createFilteredGraphData(
this.enhancedGraphData,
this.store.settings
this.store.settings,
this.noteContents
);
// Create legend
@@ -203,6 +213,26 @@ export class GraphViewContainerV2Component {
}
}, 150);
});
// New: Sync in the other direction service -> store so UI panel updates reflect in graph immediately
let applyTimer: ReturnType<typeof setTimeout> | null = null;
effect(() => {
const svcCfg = settingsService.config();
if (applyTimer) clearTimeout(applyTimer);
applyTimer = setTimeout(() => {
const cur = store.settings();
const a = JSON.stringify(cur);
const b = JSON.stringify(svcCfg);
if (a !== b) {
store.update(svcCfg);
// Kick a redraw/animation as settings changed (e.g., toggles adding nodes)
const canvas = this.canvasCmp();
if (canvas) {
canvas.animate();
}
}
}, 100);
});
}
/**