From af5656f1ffeb51256ec8928d94cd82cbdff6a15a Mon Sep 17 00:00:00 2001 From: Serraniel Date: Sat, 7 Nov 2020 16:35:02 +0100 Subject: [PATCH] #32 Implemented storage provider for chromium based browsers --- src/javascript/settings/storageProvider.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/javascript/settings/storageProvider.js b/src/javascript/settings/storageProvider.js index ade62c1..4ce2686 100644 --- a/src/javascript/settings/storageProvider.js +++ b/src/javascript/settings/storageProvider.js @@ -2,10 +2,22 @@ const { assigned } = require("../utils/helpers") class StorageProviderChromium { - storeData(key, value, callback) { + setData(key, value) { + let obj = {}; + obj[key] = value; + + this.getStorage().set(obj); } getData(key, defaultValue, callback) { + this.getStorage().get(key, items => { + if (assigned(items)) { + callback(items[key]); + } + else { + callback(defaultValue); + } + }) } getStorage() { @@ -20,7 +32,7 @@ class StorageProviderChromium { class StorageProviderFirefox { - storeData(key, value, callback) { + setData(key, value, callback) { } getData(key, defaultValue, callback) { @@ -44,7 +56,7 @@ function createStorageProvider() { } -export function globalStorageProvider() { +export function getGlobalStorageProvider() { if (!assigned(__storageProvieder)) { createStorageProvider(); }