Skip to content

Commit

Permalink
fix: app crash when switching to 3d
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingtof committed Jun 1, 2024
1 parent 0d737bd commit c09e791
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/fxc-front/src/app/components/ui/main-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');

This comment has been minimized.

Copy link
@vicb

vicb Jun 2, 2024

Owner

this will break the routing

}
}

protected createRenderRoot(): HTMLElement {
Expand Down
2 changes: 2 additions & 0 deletions apps/fxc-front/src/app/redux/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

This comment has been minimized.

Copy link
@vicb

vicb Jun 2, 2024

Owner

this selector is a bit pointless, you can get the value directly at the point of use from the state.

(This might be true for other selectors in this file unless they are re-used)

The point of selectrors is to cacche expensive computation as they are not re-computed unless the state has changed


export const groupIds = (state: RootState): Set<number> =>
new Set(state.track.tracks.ids.map((trackId) => extractGroupId(String(trackId))));

Expand Down

0 comments on commit c09e791

Please sign in to comment.