From 5077f88a4dc7c3798fe0caaab0f1f5e2727cacf9 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Sun, 21 Jan 2018 22:42:01 +0100 Subject: [PATCH 1/2] Restore latest imagery used from local storage --- modules/renderer/background.js | 1 + modules/ui/background.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/renderer/background.js b/modules/renderer/background.js index fc4fe994c..89eabc335 100644 --- a/modules/renderer/background.js +++ b/modules/renderer/background.js @@ -386,6 +386,7 @@ export function rendererBackground(context) { background.baseLayerSource( background.findSource(requested) || best || + background.findSource(context.storage('background-last-used')) || background.findSource('Bing') || first || background.findSource('none') diff --git a/modules/ui/background.js b/modules/ui/background.js index d41bd9d24..9f572960f 100644 --- a/modules/ui/background.js +++ b/modules/ui/background.js @@ -30,7 +30,7 @@ export function uiBackground(context) { var key = t('background.key'); var _customSource = context.background().findSource('custom'); - var _previousBackground; + var _previousBackground = context.background().findSource(context.storage('background-previous-last-used')); var _shown = false; var _backgroundList = d3_select(null); @@ -92,6 +92,8 @@ export function uiBackground(context) { d3_event.preventDefault(); _previousBackground = context.background().baseLayerSource(); + context.storage('background-previous-last-used', _previousBackground.id); + context.storage('background-last-used', d.id); context.background().baseLayerSource(d); _backgroundList.call(updateLayerSelections); document.activeElement.blur(); From b3da51b032bd669848b9bd77eee9ca28ecfa3fb7 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 22 Jan 2018 22:51:02 +0100 Subject: [PATCH 2/2] Restore user disabled features from local storage --- modules/renderer/features.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/renderer/features.js b/modules/renderer/features.js index 88a8d5dad..8f88e77eb 100644 --- a/modules/renderer/features.js +++ b/modules/renderer/features.js @@ -72,13 +72,13 @@ export function rendererFeatures(context) { var q = utilStringQs(window.location.hash.substring(1)); var disabled = features.disabled(); if (disabled.length) { - q.disable_features = features.disabled().join(','); + q.disable_features = disabled.join(','); } else { delete q.disable_features; } window.location.replace('#' + utilQsString(q, true)); + context.storage('disabled-features', disabled.join(',')); } - _hidden = features.hidden(); dispatch.call('change'); dispatch.call('redraw'); @@ -478,11 +478,16 @@ export function rendererFeatures(context) { features.init = function() { + var storage = context.storage('disabled-features'); + if (storage) { + var storageDisabled = storage.replace(/;/g, ',').split(','); + storageDisabled.forEach(features.disable); + } + var q = utilStringQs(window.location.hash.substring(1)); - if (q.disable_features) { - var disabled = q.disable_features.replace(/;/g, ',').split(','); - disabled.forEach(features.disable); + var hashDisabled = q.disable_features.replace(/;/g, ',').split(','); + hashDisabled.forEach(features.disable); } };