Merge pull request #235 from OfficialNoob/patch-2

Formatting changes & proxy delete support
This commit is contained in:
Ajay Ramachandran 2020-01-11 15:17:34 -05:00 committed by GitHub
commit 5348496768
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

13
SB.js
View file

@ -99,18 +99,23 @@ function configProxy() {
}); });
var handler = { var handler = {
set: function(obj, prop, value) { set(obj, prop, value) {
SB.localConfig[prop] = value; SB.localConfig[prop] = value;
chrome.storage.sync.set({ chrome.storage.sync.set({
[prop]: encodeStoredItem(value) [prop]: encodeStoredItem(value)
}); });
}, },
get: function(obj, prop) {
get(obj, prop) {
let data = SB.localConfig[prop]; let data = SB.localConfig[prop];
if(data instanceof Map) data = new MapIO(prop); if(data instanceof Map) data = new MapIO(prop);
return obj[prop] || data; return obj[prop] || data;
},
deleteProperty(obj, prop) {
chrome.storage.sync.remove(prop);
} }
}; };
@ -128,10 +133,10 @@ function fetchConfig() {
} }
function migrateOldFormats() { // Convert sponsorTimes format function migrateOldFormats() { // Convert sponsorTimes format
for (key in SB.localConfig) { for (const key in SB.localConfig) {
if (key.startsWith("sponsorTimes") && key !== "sponsorTimes" && key !== "sponsorTimesContributed") { if (key.startsWith("sponsorTimes") && key !== "sponsorTimes" && key !== "sponsorTimesContributed") {
SB.config.sponsorTimes.set(key.substr(12), SB.config[key]); SB.config.sponsorTimes.set(key.substr(12), SB.config[key]);
chrome.storage.sync.remove(key); delete SB.config[key];
} }
} }
} }