mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-18 13:38:25 +03:00
Removed deleteProperty from MapIO
This commit is contained in:
25
SB.js
25
SB.js
@@ -37,23 +37,6 @@ class MapIO {
|
|||||||
return this.map.has(key);
|
return this.map.has(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteProperty(key) {
|
|
||||||
if(key === undefined) {
|
|
||||||
return chrome.storage.sync.remove(this.id);
|
|
||||||
}
|
|
||||||
if (this.map.has(key)) {
|
|
||||||
// Proxy to map
|
|
||||||
this.map.delete(key);
|
|
||||||
// Store updated map locally
|
|
||||||
chrome.storage.sync.set({
|
|
||||||
[this.id]: encodeStoredItem(this.map)
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
size() {
|
size() {
|
||||||
return this.map.size;
|
return this.map.size;
|
||||||
}
|
}
|
||||||
@@ -67,7 +50,7 @@ class MapIO {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
clear(key) {
|
clear() {
|
||||||
this.map.clear();
|
this.map.clear();
|
||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
[this.id]: encodeStoredItem(this.map)
|
[this.id]: encodeStoredItem(this.map)
|
||||||
@@ -82,8 +65,8 @@ class MapIO {
|
|||||||
* @param {*} data
|
* @param {*} data
|
||||||
*/
|
*/
|
||||||
function encodeStoredItem(data) {
|
function encodeStoredItem(data) {
|
||||||
if(!(data instanceof Map)) return data;
|
if(!(data instanceof Map)) return data;
|
||||||
return JSON.stringify(data);
|
return JSON.stringify(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,7 +118,7 @@ function configProxy() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
deleteProperty(obj, prop) {
|
deleteProperty(obj, prop) {
|
||||||
chrome.storage.sync.remove(prop);
|
chrome.storage.sync.remove(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user