Skip to content

Commit

Permalink
CELE-29 fix: Fix type mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsobspinto committed Sep 18, 2024
1 parent 0f5b449 commit 5708b24
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const CommonAutocomplete = <T,>({
disabled={disabled}
onChange={(event: React.SyntheticEvent, value) => {
event.preventDefault();
onChange(value);
onChange(value as T);
}}
clearIcon={clearIcon}
options={options}
Expand Down
16 changes: 8 additions & 8 deletions applications/visualizer/frontend/src/models/synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,34 @@ class Synchronizer {
}
}

select(selection: EnhancedNeuron, initiator: ViewerType, contexts: Record<ViewerType, SynchronizerContext>) {
select(selection: string, initiator: ViewerType, contexts: Record<ViewerType, SynchronizerContext>) {
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<ViewerType, SynchronizerContext>) {
unSelect(selection: string, initiator: ViewerType, contexts: Record<ViewerType, SynchronizerContext>) {
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);
}
}

Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions applications/visualizer/frontend/src/models/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand Down

0 comments on commit 5708b24

Please sign in to comment.