From 5708b24fc5f7ced2233a237bef4950d97357ce11 Mon Sep 17 00:00:00 2001 From: afonso Date: Wed, 18 Sep 2024 17:43:46 +0100 Subject: [PATCH] CELE-29 fix: Fix type mismatch --- .../src/components/CustomAutocomplete.tsx | 2 +- .../frontend/src/models/synchronizer.ts | 16 ++++++++-------- .../visualizer/frontend/src/models/workspace.ts | 6 ++---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/applications/visualizer/frontend/src/components/CustomAutocomplete.tsx b/applications/visualizer/frontend/src/components/CustomAutocomplete.tsx index f5dddeec..37b5dccb 100644 --- a/applications/visualizer/frontend/src/components/CustomAutocomplete.tsx +++ b/applications/visualizer/frontend/src/components/CustomAutocomplete.tsx @@ -56,7 +56,7 @@ const CommonAutocomplete = ({ disabled={disabled} onChange={(event: React.SyntheticEvent, value) => { event.preventDefault(); - onChange(value); + onChange(value as T); }} clearIcon={clearIcon} options={options} diff --git a/applications/visualizer/frontend/src/models/synchronizer.ts b/applications/visualizer/frontend/src/models/synchronizer.ts index 2b1f6034..eb115b65 100644 --- a/applications/visualizer/frontend/src/models/synchronizer.ts +++ b/applications/visualizer/frontend/src/models/synchronizer.ts @@ -44,34 +44,34 @@ class Synchronizer { } } - select(selection: EnhancedNeuron, initiator: ViewerType, contexts: Record) { + select(selection: string, initiator: ViewerType, contexts: Record) { if (!this.canHandle(initiator)) { return; } if (!this.active) { - contexts[initiator] = [...new Set([...contexts[initiator], selection.name])]; + contexts[initiator] = [...new Set([...contexts[initiator], selection])]; return; } for (const viewer of this.viewers) { - contexts[viewer] = [...new Set([...contexts[viewer], selection.name])]; + contexts[viewer] = [...new Set([...contexts[viewer], selection])]; } } - unSelect(selection: EnhancedNeuron, initiator: ViewerType, contexts: Record) { + unSelect(selection: string, initiator: ViewerType, contexts: Record) { if (!this.canHandle(initiator)) { return; } if (!this.active) { const storedNodes = [...contexts[initiator]]; - contexts[initiator] = storedNodes.filter((n) => n !== selection.name); + contexts[initiator] = storedNodes.filter((n) => n !== selection); return; } for (const viewer of this.viewers) { const storedNodes = [...contexts[viewer]]; - contexts[viewer] = storedNodes.filter((n) => n !== selection.name); + contexts[viewer] = storedNodes.filter((n) => n !== selection); } } @@ -129,13 +129,13 @@ export class SynchronizerOrchestrator { } } - public selectNeuron(selection: EnhancedNeuron, initiator: ViewerType) { + public selectNeuron(selection: string, initiator: ViewerType) { for (const synchronizer of this.synchronizers) { synchronizer.select(selection, initiator, this.contexts); } } - public unSelectNeuron(selection: EnhancedNeuron, initiator: ViewerType) { + public unSelectNeuron(selection: string, initiator: ViewerType) { for (const synchronizer of this.synchronizers) { synchronizer.unSelect(selection, initiator, this.contexts); } diff --git a/applications/visualizer/frontend/src/models/workspace.ts b/applications/visualizer/frontend/src/models/workspace.ts index 2ceb20f5..2e4a635c 100644 --- a/applications/visualizer/frontend/src/models/workspace.ts +++ b/applications/visualizer/frontend/src/models/workspace.ts @@ -255,16 +255,14 @@ export class Workspace { } addSelection(selection: string, initiator: ViewerType) { - const selectedNeurons = this.availableNeurons[selection]; this.customUpdate((draft) => { - draft.syncOrchestrator.selectNeuron(selectedNeurons, initiator); + draft.syncOrchestrator.selectNeuron(selection, initiator); }); } removeSelection(selection: string, initiator: ViewerType) { - const selectedNeurons = this.availableNeurons[selection]; this.customUpdate((draft) => { - draft.syncOrchestrator.unSelectNeuron(selectedNeurons, initiator); + draft.syncOrchestrator.unSelectNeuron(selection, initiator); }); }