Skip to content

Commit

Permalink
v1.4.4 Change behaviour of when user arrives using params and locatio…
Browse files Browse the repository at this point in the history
…n of image processor (#142)

* Only load localstate if params are not included in url request

* Clear all params other than organizations

* Update localStorage.ts

* Removed if statement to force filter reset if url params are provided

* Update localStorage.ts

* Update localStorage.ts

* Update localStorage.ts

* Update localStorage.ts

* Update thumbnail-config.json to use different api endpoint which better supports binary formats
  • Loading branch information
bo-lu authored Sep 25, 2024
1 parent 671da88 commit a3898b8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/components/search/thumbnail-config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"eodms_use_image": true,
"thumbnail_correction_proxy_dev": "https://geocore.api.geo.ca/image-processor?url="
"thumbnail_correction_proxy_dev": "https://tiler.api.geo.ca/image-processor?url="
}
62 changes: 40 additions & 22 deletions src/reducers/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,51 @@ function checkNestedProperty(obj, props: string): boolean {

export const loadState = (): StoreEnhancer<unknown, unknown> | undefined => {
try {
const serializedState = localStorage.getItem('state');
if (serializedState === null) {
return undefined;
const urlParams = new URLSearchParams(window.location.search);
if (!urlParams.toString()) {
const serializedState = localStorage.getItem('state');
if (serializedState === null) {
return undefined;
}
const state = JSON.parse(serializedState);
if (!checkNestedProperty(state, 'mappingReducer.spatempfilter')) {
state['mappingReducer'].spatempfilter = INITSPATIALTEMPORALFILTER;
}
if (!checkNestedProperty(state, 'mappingReducer.spatialfilter')) {
state['mappingReducer'].spatialfilter = [];
}
if (!checkNestedProperty(state, 'mappingReducer.metasrcfilter')) {
state['mappingReducer'].metasrcfilter = INITMETADATASRCFILTER;
}
if (!checkNestedProperty(state, 'mappingReducer.stacfilter')) {
state['mappingReducer'].stacfilter = [];
}
if (!checkNestedProperty(state, 'mappingReducer.center')) {
state['mappingReducer'].center = INITMAINMAPINFO.center;
}
if (!checkNestedProperty(state, 'mappingReducer.zoom')) {
state['mappingReducer'].zoom = INITMAINMAPINFO.zoom;
}
if (!checkNestedProperty(state, 'mappingReducer.freezeMapSearch')) {
state['mappingReducer'].freezeMapSearch = { freeze: true };
}
return state;
}
const state = JSON.parse(serializedState);
if (!checkNestedProperty(state, 'mappingReducer.spatempfilter')) {
state['mappingReducer'].spatempfilter = INITSPATIALTEMPORALFILTER;
}
if (!checkNestedProperty(state, 'mappingReducer.spatialfilter')) {
else {
const serializedState = localStorage.getItem('state');
if (serializedState === null) {
return undefined;
}
const state = JSON.parse(serializedState);
state['mappingReducer'].spatempfilter = { extents: [], startDate: "", endDate: "" };
state['mappingReducer'].spatialfilter = [];
}
if (!checkNestedProperty(state, 'mappingReducer.metasrcfilter')) {
state['mappingReducer'].metasrcfilter = INITMETADATASRCFILTER;
}
if (!checkNestedProperty(state, 'mappingReducer.stacfilter')) {
state['mappingReducer'].metasrcfilter = { sources: [], dataCollection: '', polarization: '', orbitDirection: '' };
state['mappingReducer'].stacfilter = [];
}
if (!checkNestedProperty(state, 'mappingReducer.center')) {
state['mappingReducer'].center = INITMAINMAPINFO.center;
}
if (!checkNestedProperty(state, 'mappingReducer.zoom')) {
state['mappingReducer'].zoom = INITMAINMAPINFO.zoom;
}
if (!checkNestedProperty(state, 'mappingReducer.freezeMapSearch')) {
state['mappingReducer'].center = { lat: 54.5, lng: -115 };
state['mappingReducer'].zoom = [];
state['mappingReducer'].freezeMapSearch = { freeze: true };
return state;
}
return state;
} catch (err) {
return undefined;
}
Expand Down

0 comments on commit a3898b8

Please sign in to comment.