From 93692b974aa8328c575056bcf7c5850c4bd788ea Mon Sep 17 00:00:00 2001 From: Ruben Thoms Date: Fri, 13 Oct 2023 14:20:27 +0200 Subject: [PATCH] Fixed bug related to templates, adjusted modules, fixed linting --- frontend/src/App.tsx | 5 +++-- frontend/src/framework/Workbench.ts | 5 ++++- .../framework/components/ChannelSelect/channelSelect.tsx | 7 +------ .../dataChannelVisualizationLayer.tsx | 2 +- frontend/src/modules/TornadoChart/registerModule.ts | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 8eca54689..c3a165d2d 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -15,7 +15,7 @@ function App() { const workbench = React.useRef(new Workbench()); const queryClient = useQueryClient(); - React.useEffect(() => { + React.useEffect(function handleMount() { if (!workbench.current.loadLayoutFromLocalStorage()) { workbench.current.makeLayout(layout); } @@ -32,8 +32,9 @@ function App() { }); } - return function () { + return function handleUnmount() { workbench.current.clearLayout(); + workbench.current.resetModuleInstanceNumbers(); }; }, []); diff --git a/frontend/src/framework/Workbench.ts b/frontend/src/framework/Workbench.ts index 279d2601e..7469662ed 100644 --- a/frontend/src/framework/Workbench.ts +++ b/frontend/src/framework/Workbench.ts @@ -143,13 +143,16 @@ export class Workbench { }); } + resetModuleInstanceNumbers(): void { + this._perModuleRunningInstanceNumber = {}; + } + clearLayout(): void { for (const moduleInstance of this._moduleInstances) { this._broadcaster.unregisterAllChannelsForModuleInstance(moduleInstance.getId()); } this._moduleInstances = []; this._layout = []; - this._perModuleRunningInstanceNumber = {}; this.notifySubscribers(WorkbenchEvents.ModuleInstancesChanged); } diff --git a/frontend/src/framework/components/ChannelSelect/channelSelect.tsx b/frontend/src/framework/components/ChannelSelect/channelSelect.tsx index b2d5f226d..ec04c072f 100644 --- a/frontend/src/framework/components/ChannelSelect/channelSelect.tsx +++ b/frontend/src/framework/components/ChannelSelect/channelSelect.tsx @@ -18,11 +18,6 @@ export const ChannelSelect: React.FC = (props) => { const channel = moduleContext.useInputChannel(props.channelName); const [channels, setChannels] = React.useState([]); - if (prevInitialChannel !== props.initialChannel) { - setPrevInitialChannel(props.initialChannel); - setChannel(props.initialChannel ?? ""); - } - React.useEffect(() => { const handleChannelsChanged = (channels: BroadcastChannel[]) => { const inputChannel = moduleContext.getInputChannel(props.channelName); @@ -43,7 +38,7 @@ export const ChannelSelect: React.FC = (props) => { const unsubscribeFunc = broadcaster.subscribeToChannelsChanges(handleChannelsChanged); return unsubscribeFunc; - }, [moduleContext, broadcaster]); + }, [moduleContext, broadcaster, props.channelName]); const handleChannelsChanged = (channelName: string) => { moduleContext.setInputChannel(props.channelName, channelName); diff --git a/frontend/src/framework/internal/components/Content/private-components/DataChannelVisualizationLayer/dataChannelVisualizationLayer.tsx b/frontend/src/framework/internal/components/Content/private-components/DataChannelVisualizationLayer/dataChannelVisualizationLayer.tsx index e754134b1..1b6029e72 100644 --- a/frontend/src/framework/internal/components/Content/private-components/DataChannelVisualizationLayer/dataChannelVisualizationLayer.tsx +++ b/frontend/src/framework/internal/components/Content/private-components/DataChannelVisualizationLayer/dataChannelVisualizationLayer.tsx @@ -57,7 +57,7 @@ export const DataChannelVisualizationLayer: React.FC { let localMousePressed = false; let localCurrentOriginPoint: Point = { x: 0, y: 0 }; - let localEditDataChannelConnections: boolean = false; + let localEditDataChannelConnections = false; function handleDataChannelOriginPointerDown(payload: GuiEventPayloads[GuiEvent.DataChannelOriginPointerDown]) { const clientRect = payload.originElement.getBoundingClientRect(); diff --git a/frontend/src/modules/TornadoChart/registerModule.ts b/frontend/src/modules/TornadoChart/registerModule.ts index ce9c56c7e..c036d3205 100644 --- a/frontend/src/modules/TornadoChart/registerModule.ts +++ b/frontend/src/modules/TornadoChart/registerModule.ts @@ -7,7 +7,7 @@ import { State } from "./state"; const inputChannelDefs: InputBroadcastChannelDef[] = [ { - name: "responseChannel", + name: "response", displayName: "Response", keyCategories: [BroadcastChannelKeyCategory.Realization], },