Skip to content

Commit

Permalink
Added cache-clearing for non-tourstory actions (#4852)
Browse files Browse the repository at this point in the history
  • Loading branch information
christof-wittreich authored Dec 8, 2023
1 parent 504221b commit e397cde
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions web/js/mapUI/components/update-projection/updateProjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ function UpdateProjection(props) {
*
* @returns {void}
*/
const clearLayers = function() {
const clearLayers = function(saveCache) {
const activeLayersUI = ui.selected
.getLayers()
.getArray()
.slice(0);
lodashEach(activeLayersUI, (mapLayer) => {
ui.selected.removeLayer(mapLayer);
});

if (saveCache) return;
ui.cache.clear();
};

/**
Expand Down Expand Up @@ -116,7 +119,7 @@ function UpdateProjection(props) {
* @param {Boolean} id - layer id
* @returns {void}
*/
async function reloadLayers(granuleOptions) {
async function reloadLayers(granuleOptions, saveCache) {
const mapUI = ui.selected;
const { createLayer } = ui;

Expand All @@ -125,7 +128,7 @@ function UpdateProjection(props) {
if (compareMapDestroyed) {
compareMapUi.destroy();
}
clearLayers();
clearLayers(saveCache);
const defs = getLayers(layerState, { reverse: true });
const layerPromises = defs.map((def) => {
const options = getGranuleOptions(layerState, def, compare.activeString, granuleOptions);
Expand All @@ -138,7 +141,7 @@ function UpdateProjection(props) {
if (compare && !compare.isCompareA && compare.mode === 'spy') {
stateArray.reverse(); // Set Layer order based on active A|B group
}
clearLayers();
clearLayers(saveCache);
const stateArrayGroups = stateArray.map(async (arr) => getCompareLayerGroup(arr, layerState, granuleOptions));
const compareLayerGroups = await Promise.all(stateArrayGroups);
compareLayerGroups.forEach((layerGroup) => mapUI.addLayer(layerGroup));
Expand Down Expand Up @@ -222,7 +225,7 @@ function UpdateProjection(props) {

updateMapUI(ui, rotation);

reloadLayers();
reloadLayers(null, !start);

// If the browser was resized, the inactive map was not notified of
// the event. Force the update no matter what and reposition the center
Expand Down

0 comments on commit e397cde

Please sign in to comment.