Fix bug where sync options wouldn't be read
This commit is contained in:
parent
f923584ceb
commit
29c731224e
|
@ -5,14 +5,23 @@ function createWindowStorage(callback){
|
||||||
}
|
}
|
||||||
|
|
||||||
function createOptionsStorage(callback){
|
function createOptionsStorage(callback){
|
||||||
chrome.storage.local.set({"options":{
|
var defaultSettings = {"options":{
|
||||||
'darkMode':true,
|
'darkMode':true,
|
||||||
'sync':true,
|
'sync':true,
|
||||||
}});
|
}};
|
||||||
|
chrome.storage.local.set(defaultSettings);
|
||||||
|
chrome.storage.sync.set(defaultSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOptions(callback){
|
function getOptions(callback){
|
||||||
chrome.storage.local.get("options",callback);
|
chrome.storage.local.get("options",function(items){
|
||||||
|
if (items.sync){
|
||||||
|
chrome.storage.sync.get("options",callback);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
callback(items);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateWindowStorage(callback){
|
function populateWindowStorage(callback){
|
||||||
|
|
|
@ -13,7 +13,6 @@ function getOptions(callback){
|
||||||
|
|
||||||
function saveOptions(callback){
|
function saveOptions(callback){
|
||||||
chrome.storage.local.set({"options":options},function(){
|
chrome.storage.local.set({"options":options},function(){
|
||||||
console.log(options);
|
|
||||||
if (options.sync){
|
if (options.sync){
|
||||||
chrome.storage.sync.set({"options":options},callback);
|
chrome.storage.sync.set({"options":options},callback);
|
||||||
}
|
}
|
||||||
|
|
9
popup.js
9
popup.js
|
@ -8,7 +8,14 @@ function getStorage(callback){
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOptions(callback){
|
function getOptions(callback){
|
||||||
chrome.storage.local.get("options",callback);
|
chrome.storage.local.get("options",function(items){
|
||||||
|
if (items.sync){
|
||||||
|
chrome.storage.sync.get("options",callback);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
callback(items);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeWindowName(windowId,newName,callback){
|
function changeWindowName(windowId,newName,callback){
|
||||||
|
|
Loading…
Reference in a new issue