From c09e7915a3a439e910bfee1d07e1219db4bfc920 Mon Sep 17 00:00:00 2001 From: flyingtof Date: Sat, 1 Jun 2024 23:10:40 +0200 Subject: [PATCH] fix: app crash when switching to 3d --- apps/fxc-front/src/app/components/ui/main-menu.ts | 5 ++++- apps/fxc-front/src/app/redux/selectors.ts | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/fxc-front/src/app/components/ui/main-menu.ts b/apps/fxc-front/src/app/components/ui/main-menu.ts index 823fb9cd..765cb969 100644 --- a/apps/fxc-front/src/app/components/ui/main-menu.ts +++ b/apps/fxc-front/src/app/components/ui/main-menu.ts @@ -7,7 +7,7 @@ import { when } from 'lit/directives/when.js'; import { UnsubscribeHandle } from 'micro-typed-events'; import { connect } from 'pwa-helpers'; import { requestCurrentPosition } from '../../logic/geolocation'; -import { ParamNames, addUrlParamValues, pushCurrentState } from '../../logic/history'; +import { addUrlParamValues, getSearchParams, ParamNames, pushCurrentState } from '../../logic/history'; import * as msg from '../../logic/messages'; import { uploadTracks } from '../../logic/track'; import { DistanceUnit, formatUnit } from '../../logic/units'; @@ -526,6 +526,9 @@ export class ViewItems extends connect(store)(LitElement) { private async handleSwitch() { store.dispatch(setApiLoading(true)); await maybeHideSidePane(); + if (sel.view2d(store.getState())){ + window.open(`/3d?${getSearchParams().toString()}`, '_self'); + } } protected createRenderRoot(): HTMLElement { diff --git a/apps/fxc-front/src/app/redux/selectors.ts b/apps/fxc-front/src/app/redux/selectors.ts index dc42220c..136bf01f 100644 --- a/apps/fxc-front/src/app/redux/selectors.ts +++ b/apps/fxc-front/src/app/redux/selectors.ts @@ -14,6 +14,8 @@ export const currentTrack = (state: RootState): RuntimeTrack | undefined => export const currentTrackId = (state: RootState): string | undefined => state.track.currentTrackId; export const numTracks = trackAdapterSelector.selectTotal; +export const view2d = (state: RootState):boolean => !state.app.view3d; + export const groupIds = (state: RootState): Set => new Set(state.track.tracks.ids.map((trackId) => extractGroupId(String(trackId))));