Remove reduntant search engine update functions

This commit is contained in:
yangdx
2025-03-15 17:46:13 +08:00
parent 97696ddb76
commit a138000f0f
2 changed files with 1 additions and 20 deletions

View File

@@ -11,18 +11,3 @@ export const searchCache: {
graph: null, graph: null,
searchEngine: null searchEngine: null
} }
export const updateSearchEngine = (nodeId: string, graph: DirectedGraph) => {
if (!searchCache.searchEngine || !graph) return
const newDocument = {
id: nodeId,
label: graph.getNodeAttribute(nodeId, 'label')
}
searchCache.searchEngine.add(newDocument)
}
export const removeFromSearchEngine = (nodeId: string) => {
if (!searchCache.searchEngine) return
searchCache.searchEngine.remove({ id: nodeId })
}

View File

@@ -11,7 +11,7 @@ import { useSettingsStore } from '@/stores/settings'
import { useTabVisibility } from '@/contexts/useTabVisibility' import { useTabVisibility } from '@/contexts/useTabVisibility'
import seedrandom from 'seedrandom' import seedrandom from 'seedrandom'
import { searchCache, updateSearchEngine, removeFromSearchEngine } from '@/components/graph/graphSearchUtils' import { searchCache } from '@/components/graph/graphSearchUtils'
const validateGraph = (graph: RawGraph) => { const validateGraph = (graph: RawGraph) => {
if (!graph) { if (!graph) {
@@ -538,8 +538,6 @@ const useLightrangeGraph = () => {
rawGraph.nodes.push(newNode); rawGraph.nodes.push(newNode);
// Update nodeIdMap // Update nodeIdMap
rawGraph.nodeIdMap[nodeId] = rawGraph.nodes.length - 1; rawGraph.nodeIdMap[nodeId] = rawGraph.nodes.length - 1;
// Update search engine with new node
updateSearchEngine(nodeId, sigmaGraph);
} }
} }
@@ -707,8 +705,6 @@ const useLightrangeGraph = () => {
// Remove from nodeIdMap // Remove from nodeIdMap
delete rawGraph.nodeIdMap[nodeToDelete]; delete rawGraph.nodeIdMap[nodeToDelete];
// Remove from search engine
removeFromSearchEngine(nodeToDelete);
} }
} }