Fix data migration from 1.0 for Firefox
This commit is contained in:
parent
06193f2315
commit
4c414f729a
|
@ -41,15 +41,21 @@ chrome.runtime.onInstalled.addListener(function (details) {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Function for migrating data from version 1.0
|
// Function for migrating data from version 1.0
|
||||||
// Version 1.0 saved a single server in a "userServer" string
|
|
||||||
async function migrateOldData() {
|
async function migrateOldData() {
|
||||||
var data = await chrome.storage.sync.get()
|
// Chrome/Edge version saved a single server in a "userServer" string in chrome.storage.sync
|
||||||
|
// Firefox version saved it in "userServer" string but in chrome.local.sync
|
||||||
|
if (window.navigator.userAgent.includes('Firefox')) {
|
||||||
|
var data = await chrome.storage.local.get()
|
||||||
|
} else {
|
||||||
|
var data = await chrome.storage.sync.get()
|
||||||
|
}
|
||||||
if (data.userServer) {
|
if (data.userServer) {
|
||||||
var oldServer = data.userServer
|
var oldServer = data.userServer
|
||||||
console.log('Migrating server selection ' + oldServer + ' to new format...')
|
console.log('Migrating server selection ' + oldServer + ' to new format...')
|
||||||
// Move data
|
// Move data
|
||||||
await chrome.storage.sync.set({ serverList: [oldServer] })
|
await chrome.storage.sync.set({ serverList: [oldServer] })
|
||||||
// Delete old data
|
// Delete old data
|
||||||
|
await chrome.storage.local.clear()
|
||||||
await chrome.storage.sync.remove('userServer')
|
await chrome.storage.sync.remove('userServer')
|
||||||
console.log('Migration complete!')
|
console.log('Migration complete!')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue