Fix: settings could be empty on the first install

This commit is contained in:
eight 2018-10-04 19:34:36 +08:00
parent 2328cf623a
commit dc5f3e209f

View File

@ -103,7 +103,11 @@ var prefs = (() => {
}; };
const initializing = promisify(chrome.storage.sync.get.bind(chrome.storage.sync))('settings') const initializing = promisify(chrome.storage.sync.get.bind(chrome.storage.sync))('settings')
.then(result => setAll(result.settings, true)); .then(result => {
if (result.settings) {
setAll(result.settings, true);
}
});
chrome.storage.onChanged.addListener((changes, area) => { chrome.storage.onChanged.addListener((changes, area) => {
if (area !== 'sync' || !changes.settings || !changes.settings.newValue) { if (area !== 'sync' || !changes.settings || !changes.settings.newValue) {