From ede1187b310290d2b083b8ff0a4db6213965dc01 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 13 Aug 2017 17:33:57 +0300 Subject: [PATCH] popupWidth setting isn't a special sync case anymore --- js/prefs.js | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/js/prefs.js b/js/prefs.js index 2326036b..45adb4a7 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -193,30 +193,21 @@ var prefs = new function Prefs() { if (!BG || BG === window) { affectsIcon.forEach(key => this.broadcast(key, values[key], {sync: false})); - getSync().get('settings', ({settings: synced} = {}) => { - if (synced) { - for (const key in defaults) { - if (key === 'popupWidth' && synced[key] !== values.popupWidth) { - // this is a fix for the period when popupWidth wasn't synced - // TODO: remove it in a couple of months - continue; - } - if (key in synced) { - this.set(key, synced[key], {sync: false}); - } + const importFromSync = synced => { + for (const key in defaults) { + if (key in synced) { + this.set(key, synced[key], {sync: false}); } } - }); + }; + + getSync().get('settings', ({settings}) => importFromSync(settings)); chrome.storage.onChanged.addListener((changes, area) => { if (area === 'sync' && 'settings' in changes) { const synced = changes.settings.newValue; if (synced) { - for (const key in defaults) { - if (key in synced) { - this.set(key, synced[key], {sync: false}); - } - } + importFromSync(synced); } else { // user manually deleted our settings, we'll recreate them getSync().set({'settings': values});