diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index f80941fce..8eca54689 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,6 +1,6 @@ import React from "react"; -import { DrawerContent, GuiState, useSetGuiValue } from "@framework/GuiMessageBroker"; +import { DrawerContent, GuiState } from "@framework/GuiMessageBroker"; import { LayoutElement, Workbench } from "@framework/Workbench"; import { NavBar } from "@framework/internal/components/NavBar"; import { SettingsContentPanels } from "@framework/internal/components/SettingsContentPanels"; @@ -15,8 +15,6 @@ function App() { const workbench = React.useRef(new Workbench()); const queryClient = useQueryClient(); - const setLoadingEnsembleSet = useSetGuiValue(workbench.current.getGuiMessageBroker(), GuiState.LoadingEnsembleSet); - React.useEffect(() => { if (!workbench.current.loadLayoutFromLocalStorage()) { workbench.current.makeLayout(layout); @@ -30,7 +28,7 @@ function App() { if (storedEnsembleIdents) { workbench.current.getGuiMessageBroker().setState(GuiState.LoadingEnsembleSet, true); workbench.current.loadAndSetupEnsembleSetInSession(queryClient, storedEnsembleIdents).then(() => { - setLoadingEnsembleSet(false); + workbench.current.getGuiMessageBroker().setState(GuiState.LoadingEnsembleSet, false); }); } diff --git a/frontend/src/framework/GuiMessageBroker.ts b/frontend/src/framework/GuiMessageBroker.ts index 2f232952a..6ecc49d5a 100644 --- a/frontend/src/framework/GuiMessageBroker.ts +++ b/frontend/src/framework/GuiMessageBroker.ts @@ -169,11 +169,3 @@ export function useGuiValue(guiMessageBroker: GuiMessageBrok const [state] = useGuiState(guiMessageBroker, key); return state; } - -export function useSetGuiValue( - guiMessageBroker: GuiMessageBroker, - key: T -): (value: GuiStateTypes[T] | ((prev: GuiStateTypes[T]) => GuiStateTypes[T])) => void { - const [, setter] = useGuiState(guiMessageBroker, key); - return setter; -} diff --git a/frontend/src/framework/internal/components/Content/private-components/ViewWrapper/viewWrapper.tsx b/frontend/src/framework/internal/components/Content/private-components/ViewWrapper/viewWrapper.tsx index e1e1e145f..542caabcc 100644 --- a/frontend/src/framework/internal/components/Content/private-components/ViewWrapper/viewWrapper.tsx +++ b/frontend/src/framework/internal/components/Content/private-components/ViewWrapper/viewWrapper.tsx @@ -1,6 +1,6 @@ import React from "react"; -import { DrawerContent, GuiEvent, GuiState, useGuiState, useSetGuiValue } from "@framework/GuiMessageBroker"; +import { DrawerContent, GuiEvent, GuiState, useGuiState } from "@framework/GuiMessageBroker"; import { ModuleInstance } from "@framework/ModuleInstance"; import { Workbench } from "@framework/Workbench"; import { Point, pointDifference, pointRelativeToDomRect, pointerEventToPoint } from "@lib/utils/geometry"; @@ -33,11 +33,6 @@ export const ViewWrapper: React.FC = (props) => { GuiState.SettingsPanelWidthInPercent ); - const setActiveModuleInstanceId = useSetGuiValue( - props.workbench.getGuiMessageBroker(), - GuiState.ActiveModuleInstanceId - ); - const guiMessageBroker = props.workbench.getGuiMessageBroker(); const timeRef = React.useRef(null); @@ -76,7 +71,7 @@ export const ViewWrapper: React.FC = (props) => { setDrawerContent(DrawerContent.ModuleSettings); } if (props.isActive) return; - setActiveModuleInstanceId(props.moduleInstance.getId()); + props.workbench.getGuiMessageBroker().setState(GuiState.ActiveModuleInstanceId, props.moduleInstance.getId()); } function handlePointerDown() {