Skip to content

Commit

Permalink
Removed useSetGuiValue hook
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Oct 4, 2023
1 parent 8d46b5e commit e2bb9d3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
6 changes: 2 additions & 4 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -15,8 +15,6 @@ function App() {
const workbench = React.useRef<Workbench>(new Workbench());
const queryClient = useQueryClient();

const setLoadingEnsembleSet = useSetGuiValue(workbench.current.getGuiMessageBroker(), GuiState.LoadingEnsembleSet);

React.useEffect(() => {
if (!workbench.current.loadLayoutFromLocalStorage()) {
workbench.current.makeLayout(layout);
Expand All @@ -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);
});
}

Expand Down
8 changes: 0 additions & 8 deletions frontend/src/framework/GuiMessageBroker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,3 @@ export function useGuiValue<T extends GuiState>(guiMessageBroker: GuiMessageBrok
const [state] = useGuiState(guiMessageBroker, key);
return state;
}

export function useSetGuiValue<T extends GuiState>(
guiMessageBroker: GuiMessageBroker,
key: T
): (value: GuiStateTypes[T] | ((prev: GuiStateTypes[T]) => GuiStateTypes[T])) => void {
const [, setter] = useGuiState(guiMessageBroker, key);
return setter;
}
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -33,11 +33,6 @@ export const ViewWrapper: React.FC<ViewWrapperProps> = (props) => {
GuiState.SettingsPanelWidthInPercent
);

const setActiveModuleInstanceId = useSetGuiValue(
props.workbench.getGuiMessageBroker(),
GuiState.ActiveModuleInstanceId
);

const guiMessageBroker = props.workbench.getGuiMessageBroker();

const timeRef = React.useRef<number | null>(null);
Expand Down Expand Up @@ -76,7 +71,7 @@ export const ViewWrapper: React.FC<ViewWrapperProps> = (props) => {
setDrawerContent(DrawerContent.ModuleSettings);
}
if (props.isActive) return;
setActiveModuleInstanceId(props.moduleInstance.getId());
props.workbench.getGuiMessageBroker().setState(GuiState.ActiveModuleInstanceId, props.moduleInstance.getId());
}

function handlePointerDown() {
Expand Down

0 comments on commit e2bb9d3

Please sign in to comment.