Properly save and restore caches when entering/leaving the walkthrough

This commit is contained in:
Bryan Housel
2018-07-12 15:39:04 -04:00
parent fe7086f753
commit 19560ebc90
2 changed files with 24 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
import _chunk from 'lodash-es/chunk';
import _cloneDeep from 'lodash-es/cloneDeep';
import _extend from 'lodash-es/extend';
import _forEach from 'lodash-es/forEach';
import _filter from 'lodash-es/filter';
@@ -893,9 +894,27 @@ export default {
},
loadedTiles: function(_) {
if (!arguments.length) return _tileCache.loaded;
_tileCache.loaded = _;
caches: function(obj) {
if (!arguments.length) {
return {
tile: _cloneDeep(_tileCache),
note: _cloneDeep(_noteCache),
user: _cloneDeep(_userCache)
};
}
if (obj.tile) {
_tileCache = obj.tile;
_tileCache.inflight = {};
}
if (obj.note) {
_noteCache = obj.note;
_tileCache.inflight = {};
}
if (obj.user) {
_userCache = obj.user;
}
return this;
},
@@ -969,18 +988,6 @@ export default {
},
loadedNotes: function(_) {
if (!arguments.length) return _noteCache.loaded;
_noteCache.loaded = _;
return this;
},
notesCache: function() {
return _noteCache;
},
toggleNoteStatus: function(note, comment, callback) {
if (!(note instanceof osmNote) && !(this.getNote(note.id))) return;
if (!this.authenticated()) return;

View File

@@ -71,7 +71,7 @@ export function uiIntro(context) {
var background = context.background().baseLayerSource();
var overlays = context.background().overlayLayerSources();
var opacity = d3_selectAll('#map .layer-background').style('opacity');
var loadedTiles = osm && osm.loadedTiles();
var caches = osm && osm.caches();
var baseEntities = context.history().graph().base().entities;
var countryCode = services.geocoder.countryCode;
@@ -147,7 +147,7 @@ export function uiIntro(context) {
curtain.remove();
navwrap.remove();
d3_selectAll('#map .layer-background').style('opacity', opacity);
if (osm) { osm.toggle(true).reset().loadedTiles(loadedTiles); }
if (osm) { osm.toggle(true).reset().caches(caches); }
context.history().reset().merge(_values(baseEntities));
context.background().baseLayerSource(background);
overlays.forEach(function (d) { context.background().toggleOverlayLayer(d); });