-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable Local Storage and IndexedDB clearing for Firefox
- Loading branch information
dessant
committed
Jan 18, 2018
1 parent
21a929e
commit a6306be
Showing
5 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import browser from 'webextension-polyfill'; | ||
|
||
import {targetEnv} from 'utils/config'; | ||
|
||
const message = 'Enable localStorage and indexedDB for Firefox'; | ||
|
||
const revision = 'ByCtvupNz'; | ||
const downRevision = 'BkFsUtt7f'; | ||
|
||
const storage = browser.storage.local; | ||
|
||
async function upgrade() { | ||
const changes = {}; | ||
|
||
if (targetEnv === 'firefox') { | ||
const {dataTypes} = await storage.get('dataTypes'); | ||
|
||
changes.dataTypes = dataTypes.concat('localStorage', 'indexedDB'); | ||
} | ||
|
||
changes.storageVersion = revision; | ||
return storage.set(changes); | ||
} | ||
|
||
async function downgrade() { | ||
const changes = {}; | ||
|
||
if (targetEnv === 'firefox') { | ||
const {dataTypes, disabledDataTypes} = await storage.get([ | ||
'dataTypes', | ||
'disabledDataTypes' | ||
]); | ||
|
||
const unsupportedDataTypes = ['indexedDB', 'localStorage']; | ||
changes.dataTypes = dataTypes.filter( | ||
x => unsupportedDataTypes.indexOf(x) === -1 | ||
); | ||
changes.disabledDataTypes = disabledDataTypes.filter( | ||
x => unsupportedDataTypes.indexOf(x) === -1 | ||
); | ||
} | ||
|
||
changes.storageVersion = downRevision; | ||
return storage.set(changes); | ||
} | ||
|
||
module.exports = { | ||
message, | ||
revision, | ||
upgrade, | ||
downgrade | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"versions": ["xO0Hh1Vm2", "BkFsUtt7f"]} | ||
{"versions": ["xO0Hh1Vm2", "BkFsUtt7f", "ByCtvupNz"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import browser from 'webextension-polyfill'; | ||
|
||
import {targetEnv} from 'utils/config'; | ||
|
||
const message = 'Enable localStorage and indexedDB for Firefox'; | ||
|
||
const revision = 'ByCtvupNz'; | ||
const downRevision = 'BkFsUtt7f'; | ||
|
||
const storage = browser.storage.sync; | ||
|
||
async function upgrade() { | ||
const changes = {}; | ||
|
||
if (targetEnv === 'firefox') { | ||
const {dataTypes} = await storage.get('dataTypes'); | ||
|
||
changes.dataTypes = dataTypes.concat('localStorage', 'indexedDB'); | ||
} | ||
|
||
changes.storageVersion = revision; | ||
return storage.set(changes); | ||
} | ||
|
||
async function downgrade() { | ||
const changes = {}; | ||
|
||
if (targetEnv === 'firefox') { | ||
const {dataTypes, disabledDataTypes} = await storage.get([ | ||
'dataTypes', | ||
'disabledDataTypes' | ||
]); | ||
|
||
const unsupportedDataTypes = ['indexedDB', 'localStorage']; | ||
changes.dataTypes = dataTypes.filter( | ||
x => unsupportedDataTypes.indexOf(x) === -1 | ||
); | ||
changes.disabledDataTypes = disabledDataTypes.filter( | ||
x => unsupportedDataTypes.indexOf(x) === -1 | ||
); | ||
} | ||
|
||
changes.storageVersion = downRevision; | ||
return storage.set(changes); | ||
} | ||
|
||
module.exports = { | ||
message, | ||
revision, | ||
upgrade, | ||
downgrade | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"versions": ["xO0Hh1Vm2", "BkFsUtt7f"]} | ||
{"versions": ["xO0Hh1Vm2", "BkFsUtt7f", "ByCtvupNz"]} |