Restore user disabled features from local storage

This commit is contained in:
Gautier Pelloux-Prayer
2018-01-22 22:51:02 +01:00
parent 5077f88a4d
commit b3da51b032

View File

@@ -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);
}
};