From ee059ee9101c47f89781a0ff4cf17ea7bd5a302d Mon Sep 17 00:00:00 2001 From: Ruben Thoms <69145689+rubenthoms@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:14:20 +0100 Subject: [PATCH] fix: `LayerManagerComponentWrapper` not updating when items in `LayerManager` are changing (#829) --- frontend/src/modules/2DViewer/registerModule.ts | 3 +++ ...ManagerComponent.tsx => layerManagerComponentWrapper.tsx} | 5 +++-- frontend/src/modules/2DViewer/settings/settings.tsx | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) rename frontend/src/modules/2DViewer/settings/components/{layerManagerComponent.tsx => layerManagerComponentWrapper.tsx} (97%) diff --git a/frontend/src/modules/2DViewer/registerModule.ts b/frontend/src/modules/2DViewer/registerModule.ts index 2e29217a9..99a591b88 100644 --- a/frontend/src/modules/2DViewer/registerModule.ts +++ b/frontend/src/modules/2DViewer/registerModule.ts @@ -21,4 +21,7 @@ ModuleRegistry.registerModule({ ModuleDataTagId.GRID3D, ModuleDataTagId.POLYGONS, ], + onInstanceUnload: (instanceId) => { + window.localStorage.removeItem(`${instanceId}-settings`); + }, }); diff --git a/frontend/src/modules/2DViewer/settings/components/layerManagerComponent.tsx b/frontend/src/modules/2DViewer/settings/components/layerManagerComponentWrapper.tsx similarity index 97% rename from frontend/src/modules/2DViewer/settings/components/layerManagerComponent.tsx rename to frontend/src/modules/2DViewer/settings/components/layerManagerComponentWrapper.tsx index 54e040211..7fcd50bb4 100644 --- a/frontend/src/modules/2DViewer/settings/components/layerManagerComponent.tsx +++ b/frontend/src/modules/2DViewer/settings/components/layerManagerComponentWrapper.tsx @@ -9,7 +9,8 @@ import { MenuButton } from "@lib/components/MenuButton"; import { MenuHeading } from "@lib/components/MenuHeading"; import { MenuItem } from "@lib/components/MenuItem"; import { LayersActionGroup } from "@modules/2DViewer/layers/LayersActions"; -import { GroupDelegate } from "@modules/2DViewer/layers/delegates/GroupDelegate"; +import { GroupDelegate, GroupDelegateTopic } from "@modules/2DViewer/layers/delegates/GroupDelegate"; +import { usePublishSubscribeTopicValue } from "@modules/2DViewer/layers/delegates/PublishSubscribeDelegate"; import { ColorScale } from "@modules/2DViewer/layers/framework/ColorScale/ColorScale"; import { DeltaSurface } from "@modules/2DViewer/layers/framework/DeltaSurface/DeltaSurface"; import { LayerManager } from "@modules/2DViewer/layers/framework/LayerManager/LayerManager"; @@ -53,10 +54,10 @@ export type LayerManagerComponentWrapperProps = { export function LayerManagerComponentWrapper(props: LayerManagerComponentWrapperProps): React.ReactNode { const colorSet = props.workbenchSettings.useColorSet(); - const [preferredViewLayout, setPreferredViewLayout] = useAtom(preferredViewLayoutAtom); const groupDelegate = props.layerManager.getGroupDelegate(); + usePublishSubscribeTopicValue(groupDelegate, GroupDelegateTopic.CHILDREN); function handleLayerAction(identifier: string, groupDelegate: GroupDelegate) { const numSharedSettings = groupDelegate.findChildren((item) => { diff --git a/frontend/src/modules/2DViewer/settings/settings.tsx b/frontend/src/modules/2DViewer/settings/settings.tsx index 3c62c719e..5f8b30702 100644 --- a/frontend/src/modules/2DViewer/settings/settings.tsx +++ b/frontend/src/modules/2DViewer/settings/settings.tsx @@ -10,7 +10,7 @@ import { useAtom, useAtomValue, useSetAtom } from "jotai"; import { layerManagerAtom, preferredViewLayoutAtom, userSelectedFieldIdentifierAtom } from "./atoms/baseAtoms"; import { selectedFieldIdentifierAtom } from "./atoms/derivedAtoms"; -import { LayerManagerComponentWrapper } from "./components/layerManagerComponent"; +import { LayerManagerComponentWrapper } from "./components/layerManagerComponentWrapper"; import { GroupDelegateTopic } from "../layers/delegates/GroupDelegate"; import { LayerManager, LayerManagerTopic } from "../layers/framework/LayerManager/LayerManager";