Fixed settings conversion on update
This commit is contained in:
parent
b6c98028b9
commit
2a239a2fb2
|
@ -642,7 +642,6 @@ async function reverse(url) {
|
||||||
case "imdb":
|
case "imdb":
|
||||||
case "imgur":
|
case "imgur":
|
||||||
case "tiktok":
|
case "tiktok":
|
||||||
case "twitter":
|
|
||||||
case "reddit":
|
case "reddit":
|
||||||
case "imdb":
|
case "imdb":
|
||||||
case "snopes":
|
case "snopes":
|
||||||
|
@ -702,7 +701,6 @@ const defaultInstances = {
|
||||||
'4get': ['https://4get.ca'],
|
'4get': ['https://4get.ca'],
|
||||||
'rimgo': ['https://rimgo.vern.cc'],
|
'rimgo': ['https://rimgo.vern.cc'],
|
||||||
'hyperpipe': ['https://hyperpipe.surge.sh'],
|
'hyperpipe': ['https://hyperpipe.surge.sh'],
|
||||||
'facil': [' https://facilmap.org '],
|
|
||||||
'osm': ['https://www.openstreetmap.org'],
|
'osm': ['https://www.openstreetmap.org'],
|
||||||
'breezeWiki': ['https://breezewiki.com'],
|
'breezeWiki': ['https://breezewiki.com'],
|
||||||
'neuters': ['https://neuters.de'],
|
'neuters': ['https://neuters.de'],
|
||||||
|
@ -749,12 +747,12 @@ function initDefaults() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
options['exceptions'] = {
|
options.exceptions = {
|
||||||
url: [],
|
url: [],
|
||||||
regex: [],
|
regex: [],
|
||||||
}
|
}
|
||||||
options.theme = "detect"
|
options.theme = "detect"
|
||||||
options.popupServices = ["youtube", "twitter", "tiktok", "imgur", "reddit", "quora", "translate", "maps"]
|
options.popupServices = ["youtube", "tiktok", "imgur", "reddit", "quora", "translate", "maps"]
|
||||||
options.fetchInstances = 'github'
|
options.fetchInstances = 'github'
|
||||||
options.redirectOnlyInIncognito = false
|
options.redirectOnlyInIncognito = false
|
||||||
|
|
||||||
|
@ -781,28 +779,27 @@ function upgradeOptions() {
|
||||||
|
|
||||||
function processUpdate() {
|
function processUpdate() {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
let config = await utils.getConfig()
|
let frontends = []
|
||||||
|
const config = await utils.getConfig()
|
||||||
let options = await utils.getOptions()
|
let options = await utils.getOptions()
|
||||||
for (const service in config.services) {
|
for (const service in config.services) {
|
||||||
if (!options[service]) options[service] = {}
|
if (!options[service]) options[service] = {}
|
||||||
|
|
||||||
if (!(options[service].frontend in config.services[service].frontends)) {
|
if (!(options[service].frontend in config.services[service].frontends)) {
|
||||||
options[service] = config.services[service].options
|
options[service] = config.services[service].options // Reset settings for service
|
||||||
delete options[options[service].frontend]
|
delete options[options[service].frontend] // Remove deprecated frontend
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const defaultOption in config.services[service].options) {
|
for (const defaultOption in config.services[service].options) {
|
||||||
if (options[service][defaultOption] === undefined) {
|
if (!(defaultOption in options[service])) {
|
||||||
options[service][defaultOption] = config.services[service].options[defaultOption]
|
options[service][defaultOption] = config.services[service].options[defaultOption]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const frontend in config.services[service].frontends) {
|
for (const frontend in config.services[service].frontends) {
|
||||||
if (options[frontend] === undefined && config.services[service].frontends[frontend].instanceList) {
|
frontends.push(frontend)
|
||||||
options[frontend] = defaultInstances[frontend]
|
if (!(frontend in options) && config.services[service].frontends[frontend].instanceList) {
|
||||||
}
|
options[frontend] = defaultInstances[frontend] || []
|
||||||
else if (frontend in options && !(frontend in config.services[service].frontends)) {
|
|
||||||
delete options[frontend]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,6 +810,20 @@ function processUpdate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const general = ['theme', 'popupServices', 'fetchInstances', 'redirectOnlyInIncognito']
|
||||||
|
const combined = [
|
||||||
|
...Object.keys(config.services),
|
||||||
|
...frontends,
|
||||||
|
...general,
|
||||||
|
'exceptions',
|
||||||
|
'popupServices',
|
||||||
|
'version',
|
||||||
|
]
|
||||||
|
for (const key in options) {
|
||||||
|
if (combined.indexOf(key) < 0) {
|
||||||
|
delete options[key] // Remove any unknown settings in options
|
||||||
|
}
|
||||||
|
}
|
||||||
browser.storage.local.set({ options }, () => {
|
browser.storage.local.set({ options }, () => {
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
|
|
|
@ -51,7 +51,7 @@ section(class="block-option" id="general_page")
|
||||||
path(d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z")
|
path(d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z")
|
||||||
|
|
|
|
||||||
x(data-localise="__MSG_importSettings__") Import Settings
|
x(data-localise="__MSG_importSettings__") Import Settings
|
||||||
input(id="import-settings" type="file" style="display: none")
|
input(id="import-settings" type="file" accept=".json" style="display: none")
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue