diff --git a/src/atlasComponents/userAnnotations/tools/service.ts b/src/atlasComponents/userAnnotations/tools/service.ts index 9ef8d363ac2a1201e28854b1b940d44967f5def6..5fa7acf9251d3ced3358c2284d670b05ddaca300 100644 --- a/src/atlasComponents/userAnnotations/tools/service.ts +++ b/src/atlasComponents/userAnnotations/tools/service.ts @@ -260,6 +260,7 @@ export class ModularUserAnnotationToolService implements OnDestroy{ #voxelSize = this.store.pipe( select(atlasSelection.selectors.selectedTemplate), + filter(v => !!v), switchMap(tmpl => translateV3Entities.translateSpaceToVolumeImage(tmpl)), map(volImages => { if (volImages.length === 0) { diff --git a/src/atlasComponents/userAnnotations/tools/type.ts b/src/atlasComponents/userAnnotations/tools/type.ts index d54b231afd55ca503430125855acdc6701c3fb72..a100ebcf4953a89fedc55df1c5880db5b2e13b05 100644 --- a/src/atlasComponents/userAnnotations/tools/type.ts +++ b/src/atlasComponents/userAnnotations/tools/type.ts @@ -336,7 +336,12 @@ export abstract class IAnnotationGeometry extends Highlightable { constructor(spec?: TBaseAnnotationGeomtrySpec){ super() this.id = spec && spec.id || getUuid() - this.space = spec?.space + + // older version of annotations were made with at_id as key + // fallback + const spaceId = spec?.space?.id || spec?.space?.['@id'] + + this.space = spaceId && { id: spaceId } this.name = spec?.name this.desc = spec?.desc } diff --git a/src/routerModule/effects.ts b/src/routerModule/effects.ts index ec7c34de0744bcc94464d7f248534a582f17745b..4ef7d676e5169ecd6c579a186c41d6cf0b72a81e 100644 --- a/src/routerModule/effects.ts +++ b/src/routerModule/effects.ts @@ -67,7 +67,11 @@ export class RouterEffects { return generalActions.generalApplyState({ state }) - }) + }), + switchMap(ac => from([ + ac, + generalActions.routeParseComplete() + ])) )) onRouteUpdate$ = createEffect(() => this.#atlasesLoaded$.pipe( diff --git a/src/state/actions.ts b/src/state/actions.ts index 67b9df55d8b833dd18ae0029b9ab6a90f08e7172..c6801c1328660ee66b4c319f17dec6a52189d318 100644 --- a/src/state/actions.ts +++ b/src/state/actions.ts @@ -15,6 +15,10 @@ export const generalApplyState = createAction( }>() ) +export const routeParseComplete = createAction( + `${nameSpace} routeParseComplete` +) + export const noop = createAction( `${nameSpace} noop` ) \ No newline at end of file diff --git a/src/state/index.ts b/src/state/index.ts index aa9964ec9c0a69f063874b6a8b65382a72e2025c..77c5f08d0fe4d4976c063f2581586e6461fc49ff 100644 --- a/src/state/index.ts +++ b/src/state/index.ts @@ -31,6 +31,34 @@ function debug(reducer: ActionReducer<MainState>): ActionReducer<MainState> { }; } +function gateKeepUntilRouteParseComplete(reducer: ActionReducer<MainState>): ActionReducer<MainState>{ + let completeFlag = false + const actions = [] + return function(state, action) { + const isSystem = action.type.includes("@ngrx") + if (completeFlag || isSystem) { + return reducer(state, action) + } + + let _state = state + if (action.type === routeParseComplete.type) { + while (actions.length > 0) { + const _action = actions.shift() // FIFO + _state = reducer(_state, _action) + } + completeFlag = true + return reducer(_state, action) + } + + if (action.type === generalApplyState.type) { + + return reducer(state, action) + } + actions.push(action) + return reducer(state, noop) + } +} + function generalApplyStateReducer(reducer: ActionReducer<MainState>): ActionReducer<MainState> { return function(_state, action) { let state = _state @@ -55,6 +83,7 @@ export const RootStoreModule = StoreModule.forRoot({ [atlasAppearance.nameSpace]: atlasAppearance.reducer, },{ metaReducers: [ + gateKeepUntilRouteParseComplete, generalApplyStateReducer, // debug, ] @@ -77,7 +106,7 @@ export function getStoreEffects() { } import { MainState } from "./const" -import { generalApplyState } from "./actions" +import { generalApplyState, routeParseComplete, noop } from "./actions" export { MainState }