From f84b560351c3afd760602c8d955e794cc778d1d5 Mon Sep 17 00:00:00 2001 From: Davide Passoni Date: Thu, 12 Dec 2024 16:56:11 +0100 Subject: [PATCH] fix: map sources not being loaded correctly in static version --- frontend/react/src/ui/panels/header.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/react/src/ui/panels/header.tsx b/frontend/react/src/ui/panels/header.tsx index 43bcc50e..972ca587 100644 --- a/frontend/react/src/ui/panels/header.tsx +++ b/frontend/react/src/ui/panels/header.tsx @@ -35,8 +35,11 @@ export function Header() { MapOptionsChangedEvent.on((mapOptions) => setMapOptions({ ...mapOptions })); MapSourceChangedEvent.on((source) => setMapSource(source)); ConfigLoadedEvent.on((config: OlympusConfig) => { - var sources = Object.keys(getApp().getMap().getMirrors()).concat(getApp().getMap().getLayers()); - setMapSources(sources); + // Timeout needed to make sure the map configuration has updated + window.setTimeout(() => { + var sources = Object.keys(getApp().getMap().getMirrors()).concat(getApp().getMap().getLayers()); + setMapSources(sources); + }, 200); }); CommandModeOptionsChangedEvent.on((commandModeOptions) => { setCommandModeOptions(commandModeOptions); @@ -116,7 +119,9 @@ export function Header() { )}
{ getApp().getMap().setOption("tabletMode", !mapOptions.tabletMode); }}