Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed "Open in JsBin/JsFiddle", switched localstorage to chrome.storage.local #71

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Switched localstorage to chrome.storage.local as per FIXME
Resolved as Bug is fixed: "FIXME Can be replaced with chrome.storage.local as soon as http://crbug.com/178618 will be resolved"
  • Loading branch information
KartikSoneji authored Jan 10, 2020
commit 197faab1dc57b230c5eed145546fe34363609262
20 changes: 11 additions & 9 deletions js/background.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
/*
Allows to read, change and override settings kept in localStorage

FIXME Can be replaced with chrome.storage.local as soon as http://crbug.com/178618 will be resolved
FIXME Can be replaced with localStorage on the panel page as soon as http://crbug.com/319328 will be resolved
*/
chrome.runtime.onMessage.addListener(function (message, sender, callback) {
chrome.runtime.onMessage.addListener((message, sender, callback) => {
"use strict";

if (message.name === 'getSettings') {
if(message.name === 'getSettings')
callback(localStorage);
} else if (message.name === 'setSettings') {
localStorage = message.data;
} else if (message.name === 'changeSetting') {
localStorage[message.item] = message.value;

else if(message.name === 'setSettings')
chrome.storage.local.set(message.data);

else if(message.name === 'changeSetting') {
let data = {};
data[message.item] = message.value;

chrome.storage.local.set(data);
}
});