Skip to content

Commit

Permalink
flush last render cache on reset and move set loading false to end
Browse files Browse the repository at this point in the history
  • Loading branch information
okauppinen committed Nov 27, 2024
1 parent 61c97aa commit 4b0802b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bundles/statistics/statsgrid/components/RegionsetViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Oskari.clazz.define('Oskari.statistics.statsgrid.RegionsetViewer', function (ins
}
this._lastRenderCache.highlightRegionId = activeRegion;
},
flushLastRenderStateCache: function () {
this._lastRenderStateForSelectedRegionOptimizing = {};
},
isOnlyActiveRegionChange: function (state = {}) {
const sameRegionset = this._lastRenderStateForSelectedRegionOptimizing.regionset === state.regionset;
const sameIndicator = this._lastRenderStateForSelectedRegionOptimizing.activeIndicator === state.activeIndicator;
Expand Down
4 changes: 3 additions & 1 deletion bundles/statistics/statsgrid/handler/StatisticsHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class StatisticsController extends AsyncStateHandler {
}
this.updateState({ loading: true });
try {
this.instance.regionsetViewer?.flushLastRenderStateCache();
let active;
const indicatorsToAdd = [];
// async/await doesn't work with forEach()
Expand All @@ -206,14 +207,15 @@ class StatisticsController extends AsyncStateHandler {
}
};
const isSeriesActive = active ? !!active.series : false;
this.updateState({ activeIndicator, isSeriesActive, activeRegion, regionset, indicators: indicatorsToAdd, loading: false });
this.updateState({ activeIndicator, isSeriesActive, activeRegion, regionset, indicators: indicatorsToAdd });
// reset active
if (!active) {
this.setActiveIndicator();
}
} catch (error) {
this.log.warn('Failed to set stored state', error.message);
}
this.updateState({ loading: false });
}

async onCacheUpdate (indicator, onlyData) {
Expand Down

0 comments on commit 4b0802b

Please sign in to comment.