Skip to content

Commit a287cb9

Browse files
committed
PB-1383: Avoid concurrency between app setup and URL parsing
Issue: When starting the app for the first time, the URL sync plugin would start being active before the topics were fully set, causing (mainly) the background layer parameter to be ignored and replaced with the topic's default one Fix: The `ConfigLoaded` state now wait for the background layer to be set before being fulfilled.
1 parent 31b00d8 commit a287cb9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/viewer/src/store/modules/app/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const mapShown: AppState = {
2929
const ready: AppState = {
3030
name: AppStateNames.Ready,
3131
isFulfilled: () => {
32+
console.error('ARE WE HERE AT SOME POINT ?')
3233
const mapStore = useMapStore()
3334
const cesiumStore = useCesiumStore()
3435
if (cesiumStore.active) {
@@ -51,15 +52,17 @@ const initiateUrlParsing: AppState = {
5152

5253
const parseLegacyUrlParams: AppState = {
5354
name: AppStateNames.LegacyParsing,
54-
isFulfilled: () => !isLegacyParams(window?.location?.search),
55+
isFulfilled: () => {
56+
return !isLegacyParams(window?.location?.search)
57+
},
5558
next: () => {
5659
return initiateUrlParsing
5760
},
5861
}
5962

6063
const configLoaded: AppState = {
6164
name: AppStateNames.ConfigLoaded,
62-
isFulfilled: () => true, // there's always a topic set, so no need to check if topicStore.current is defined
65+
isFulfilled: () => true,
6366
next: () => {
6467
if (isLegacyParams(window?.location?.search)) {
6568
return parseLegacyUrlParams

packages/viewer/src/store/plugins/storeSync/params/bgLayer.param.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const backgroundLayerParamConfig = new UrlParamConfig<string>({
3434
queryValue,
3535
!!queryValue &&
3636
(queryValue === 'void' ||
37-
useLayersStore().backgroundLayers?.some((layer) => layer.id == queryValue)),
37+
useLayersStore().backgroundLayers?.some((layer) => layer.id === queryValue)),
3838
'bgLayer'
3939
),
4040
})

0 commit comments

Comments
 (0)