aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/local-store.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/scripts/lib/local-store.js b/app/scripts/lib/local-store.js
new file mode 100644
index 000000000..9e8d8db37
--- /dev/null
+++ b/app/scripts/lib/local-store.js
@@ -0,0 +1,24 @@
+// We should not rely on local storage in an extension!
+// We should use this instead!
+// https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/storage/local
+
+const extension = require('extensionizer')
+
+module.exports = class ExtensionStore {
+ constructor() {
+ this.isSupported = !!(extension.storage.local)
+ if (!this.isSupported) {
+ log.error('Storage local API not available.')
+ }
+ }
+ get() {
+ return new Promise((resolve) => {
+ extension.storage.local.get(null, resolve)
+ })
+ }
+ set(state) {
+ return new Promise((resolve) => {
+ extension.storage.local.set(state, resolve)
+ })
+ }
+}