From bed67cdfbceb12cfb4d9900312e95468cbb32a34 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Fri, 15 Dec 2023 14:43:15 +0100 Subject: [PATCH] chore: cleanup --- src/AppWrapper.js | 6 +++++- src/components/app/FileMenu.js | 9 --------- src/components/app/useLoadMap.js | 25 ++++--------------------- 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/AppWrapper.js b/src/AppWrapper.js index a6a80ac63..9a6dbe129 100644 --- a/src/AppWrapper.js +++ b/src/AppWrapper.js @@ -40,7 +40,7 @@ const d2Config = { ], } -const AppWrapper = () => { +const replaceLegacyUrl = () => { // support legacy urls const queryParams = queryString.parse(window.location.search, { parseBooleans: true, @@ -74,6 +74,10 @@ const AppWrapper = () => { window.history.replaceState({}, '', `${base}#/currentAnalyticalObject`) history.replace('/currentAnalyticalObject') } +} + +const AppWrapper = () => { + replaceLegacyUrl() return ( diff --git a/src/components/app/FileMenu.js b/src/components/app/FileMenu.js index 772d02eb5..d5e11f0f8 100644 --- a/src/components/app/FileMenu.js +++ b/src/components/app/FileMenu.js @@ -65,8 +65,6 @@ const FileMenu = ({ onFileMenuAction }) => { const fileMenuErrorAlert = useAlert(ALERT_MESSAGE_DYNAMIC, ALERT_CRITICAL) const onSaveComplete = ({ id, name, isSaveAs }) => { - console.log('jj onSaveComplete', id, name, isSaveAs) - if (isSaveAs) { saveAsAlert.show({ msg: getSavedMessage(name) }) } else { @@ -81,13 +79,6 @@ const FileMenu = ({ onFileMenuAction }) => { isSaving: true, } - // const onSaveAsComplete = async (res) => { - // // const newMapConfig = await fetchMap(newMapId, engine, defaultBasemap) - // // delete newMapConfig.basemap - // // delete newMapConfig.mapViews - // // dispatch(setMapProps(newMapConfig)) - // } - if (isSaveAs) { history.push(locationObject, locationState) } else { diff --git a/src/components/app/useLoadMap.js b/src/components/app/useLoadMap.js index a39b8ee82..2f6b2b80d 100644 --- a/src/components/app/useLoadMap.js +++ b/src/components/app/useLoadMap.js @@ -24,32 +24,20 @@ import history from '../../util/history.js' import { fetchMap } from '../../util/requests.js' const getUrlParams = (hashLocation) => { - const hashQueryParams = queryString.parse(hashLocation.search, { + const params = queryString.parse(hashLocation.search, { parseBooleans: true, }) - const params = {} const pathParts = hashLocation.pathname.slice(1).split('/') if (pathParts[0]) { - if (pathParts[0]?.length === 11) { - params.mapId = pathParts[0] - } else if (pathParts[0] === 'currentAnalyticalObject') { + if (pathParts[0] === 'currentAnalyticalObject') { params.isCurrentAO = true } else { - // TODO throw error - unrecognized path + params.mapId = pathParts[0] } + if (pathParts[1] === 'download') { params.isDownload = true - - if (hashQueryParams.isPushAnalytics) { - params.isPushAnalytics = true - } - } - - if (params.mapId) { - params.interpretationId = hashQueryParams.interpretationId - - params.initialFocus = hashQueryParams.initialFocus } } @@ -70,8 +58,6 @@ export const useLoadMap = () => { const loadMap = useCallback( async (hashLocation) => { - console.log('jj loadMap') - if (hashLocation.pathname === '/') { dispatch(newMap()) return @@ -88,7 +74,6 @@ export const useLoadMap = () => { if (mapId) { try { - // throw new Error('test') const map = await fetchMap(mapId, engine, defaultBasemap) engine.mutate(dataStatisticsMutation, { @@ -185,8 +170,6 @@ export const useLoadMap = () => { !isDownloadOpening && !isDownloadClosing - // TODO navigation confirm dialog - if (isDownloadOpening) { dispatch( setDownloadMode({