mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 02:58:09 +01:00
25 lines
635 B
JavaScript
25 lines
635 B
JavaScript
// 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)
|
|
})
|
|
}
|
|
}
|