refactor: migrate graph canvas to use web worker for force layout computation
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user