#32 Added implementation for firefox api

This commit is contained in:
Serraniel 2020-11-08 13:01:05 +01:00
parent bdd94e030a
commit bce216205f
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3

View file

@ -32,13 +32,32 @@ class StorageProviderChromium {
class StorageProviderFirefox { class StorageProviderFirefox {
setData(key, value, callback) { setData(key, value) {
let obj = {};
obj[key] = value;
this.getStorage().set(obj);
} }
getData(key, defaultValue, callback) { getData(key, defaultValue, callback) {
let promise = this.getStorage().get(key);
promise.then(items => {
if (assigned(items) && assigned(items[key])) {
callback(items[key]);
}
else {
callback(defaultValue);
}
});
} }
getStorage() { getStorage() {
if (assigned(browser.storage.sync)) {
return browser.storage.sync;
}
return browser.storage.local;
} }
} }