Skip to content

Commit

Permalink
Clear all params other than organizations
Browse files Browse the repository at this point in the history
  • Loading branch information
bo-lu committed Sep 13, 2024
1 parent 304b2aa commit 5c793cf
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/reducers/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function checkNestedProperty(obj, props: string): boolean {
export const loadState = (): StoreEnhancer<unknown, unknown> | undefined => {
try {
const urlParams = new URLSearchParams(window.location.search);
if (!urlParams.toString()) {
if (!urlParams.toString()) {
const serializedState = localStorage.getItem('state');
if (serializedState === null) {
return undefined;
Expand Down Expand Up @@ -45,6 +45,35 @@ export const loadState = (): StoreEnhancer<unknown, unknown> | undefined => {
}
return state;
}
else {
const serializedState = localStorage.getItem('state');
if (serializedState === null) {
return undefined;
}
const state = JSON.parse(serializedState);
if (!checkNestedProperty(state, 'mappingReducer.spatempfilter')) {
state['mappingReducer'].spatempfilter = [];
}
if (!checkNestedProperty(state, 'mappingReducer.spatialfilter')) {
state['mappingReducer'].spatialfilter = [];
}
if (!checkNestedProperty(state, 'mappingReducer.metasrcfilter')) {
state['mappingReducer'].metasrcfilter = [];
}
if (!checkNestedProperty(state, 'mappingReducer.stacfilter')) {
state['mappingReducer'].stacfilter = [];
}
if (!checkNestedProperty(state, 'mappingReducer.center')) {
state['mappingReducer'].center = [];
}
if (!checkNestedProperty(state, 'mappingReducer.zoom')) {
state['mappingReducer'].zoom = [];
}
if (!checkNestedProperty(state, 'mappingReducer.freezeMapSearch')) {
state['mappingReducer'].freezeMapSearch = { freeze: true };
}
return state;
}
} catch (err) {
return undefined;
}
Expand Down

0 comments on commit 5c793cf

Please sign in to comment.