#32 Implemented storage provider for chromium based browsers

This commit is contained in:
Serraniel 2020-11-07 16:35:02 +01:00
parent 20eca07408
commit af5656f1ff
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3

View file

@ -2,10 +2,22 @@ const { assigned } = require("../utils/helpers")
class StorageProviderChromium { class StorageProviderChromium {
storeData(key, value, callback) { setData(key, value) {
let obj = {};
obj[key] = value;
this.getStorage().set(obj);
} }
getData(key, defaultValue, callback) { getData(key, defaultValue, callback) {
this.getStorage().get(key, items => {
if (assigned(items)) {
callback(items[key]);
}
else {
callback(defaultValue);
}
})
} }
getStorage() { getStorage() {
@ -20,7 +32,7 @@ class StorageProviderChromium {
class StorageProviderFirefox { class StorageProviderFirefox {
storeData(key, value, callback) { setData(key, value, callback) {
} }
getData(key, defaultValue, callback) { getData(key, defaultValue, callback) {
@ -44,7 +56,7 @@ function createStorageProvider() {
} }
export function globalStorageProvider() { export function getGlobalStorageProvider() {
if (!assigned(__storageProvieder)) { if (!assigned(__storageProvieder)) {
createStorageProvider(); createStorageProvider();
} }