Fix bug where sync options wouldn't be read

This commit is contained in:
Nick Krichevsky 2015-03-07 15:16:07 -05:00
parent f923584ceb
commit 29c731224e
3 changed files with 20 additions and 5 deletions

View file

@ -5,14 +5,23 @@ function createWindowStorage(callback){
}
function createOptionsStorage(callback){
chrome.storage.local.set({"options":{
var defaultSettings = {"options":{
'darkMode':true,
'sync':true,
}});
}};
chrome.storage.local.set(defaultSettings);
chrome.storage.sync.set(defaultSettings);
}
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){

View file

@ -13,7 +13,6 @@ function getOptions(callback){
function saveOptions(callback){
chrome.storage.local.set({"options":options},function(){
console.log(options);
if (options.sync){
chrome.storage.sync.set({"options":options},callback);
}

View file

@ -8,7 +8,14 @@ function getStorage(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){