fix: Replace global searchCache with Zustand state management

This commit is contained in:
yangdx
2025-03-16 02:40:48 +08:00
parent 6b2e4186ac
commit eb17a7782d
4 changed files with 38 additions and 42 deletions

View File

@@ -11,7 +11,6 @@ import { useSettingsStore } from '@/stores/settings'
import { useTabVisibility } from '@/contexts/useTabVisibility'
import seedrandom from 'seedrandom'
import { searchCache } from '@/components/graph/graphSearchUtils'
const validateGraph = (graph: RawGraph) => {
if (!graph) {
@@ -599,9 +598,8 @@ const useLightrangeGraph = () => {
// Update the dynamic edge map and invalidate search cache
rawGraph.buildDynamicMap();
// Force search engine rebuild by invalidating cache
searchCache.graph = null;
searchCache.searchEngine = null;
// Reset search engine to force rebuild
useGraphStore.getState().resetSearchEngine();
// Update sizes for all nodes with discarded edges
updateNodeSizes(sigmaGraph, nodesWithDiscardedEdges, minDegree, range, scale);
@@ -718,9 +716,8 @@ const useLightrangeGraph = () => {
// Rebuild the dynamic edge map and invalidate search cache
rawGraph.buildDynamicMap();
// Force search engine rebuild by invalidating cache
searchCache.graph = null;
searchCache.searchEngine = null;
// Reset search engine to force rebuild
useGraphStore.getState().resetSearchEngine();
// Show notification if we deleted more than just the selected node
if (nodesToDelete.size > 1) {