Skip to content

Commit

Permalink
Merge pull request #4720 from bagage/master
Browse files Browse the repository at this point in the history
Restore last imageries used and disable features from local storage
  • Loading branch information
bhousel authored Jan 23, 2018
2 parents 7d4f81e + b3da51b commit ffc68d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions modules/renderer/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
15 changes: 10 additions & 5 deletions modules/renderer/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
}
};

Expand Down
4 changes: 3 additions & 1 deletion modules/ui/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit ffc68d1

Please sign in to comment.