diff options
| author | Hygna <hygna@proton.me> | 2022-10-21 19:24:55 +0100 |
|---|---|---|
| committer | Hygna <hygna@proton.me> | 2022-10-21 19:25:50 +0100 |
| commit | 51bb4e1557b892f94132131aa6d19e5cb2b148d0 (patch) | |
| tree | 5b48f4fa91293340a0c9c0562d07bd2858d4b8ac /src/assets | |
| parent | Bump versiom 2.3.1 => 2.3.2 (diff) | |
| download | libredirect-51bb4e1557b892f94132131aa6d19e5cb2b148d0.zip | |
Fixed redirect toggles set to false being reset
Closes https://github.com/libredirect/libredirect/issues/499
Diffstat (limited to 'src/assets')
| -rw-r--r-- | src/assets/javascripts/services.js | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 7b73d9d5..8aa044ea 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -716,7 +716,11 @@ function processUpdate() { for (const service in config.services) {
if (!options[service]) options[service] = {}
if (config.services[service].targets == "datajson") targets[service] = redirects[service]
- for (const defaultOption in config.services[service].options) if (!options[service][defaultOption]) options[service][defaultOption] = config.services[service].options[defaultOption]
+ for (const defaultOption in config.services[service].options) {
+ if (options[service][defaultOption] === undefined) {
+ options[service][defaultOption] = config.services[service].options[defaultOption]
+ }
+ }
for (const frontend in config.services[service].frontends) {
if (config.services[service].frontends[frontend].instanceList) {
if (!options[frontend]) options[frontend] = {}
@@ -733,6 +737,11 @@ function processUpdate() { }
}
}
+ } else {
+ for (const instance of options[frontend][network].enabled) {
+ let i = redirects[frontend][network].indexOf(instance)
+ if (i < 0) options[frontend][network].enabled.splice(i, 1)
+ }
}
}
}
@@ -784,34 +793,6 @@ function modifyContentSecurityPolicy(details) { }
}
-function processEnabledInstanceList() {
- return new Promise(resolve => {
- fetch("/config/config.json")
- .then(response => response.text())
- .then(configData => {
- const config = JSON.parse(configData)
- browser.storage.local.get(["redirects", "options"], r => {
- let options = r.options
- for (const service in config.services) {
- for (const frontend in config.services[service].frontends) {
- if (config.services[service].frontends[frontend].instanceList) {
- for (const network in config.networks) {
- for (const instance of options[frontend][network].enabled) {
- let i = redirects[frontend][network].indexOf(instance)
- if (i < 0) options[frontend][network].enabled.splice(i, 1)
- }
- }
- }
- }
- }
- browser.storage.local.set({ options }, () => {
- resolve()
- })
- })
- })
- })
-}
-
export default {
redirect,
computeService,
@@ -823,5 +804,4 @@ export default { upgradeOptions,
processUpdate,
modifyContentSecurityPolicy,
- processEnabledInstanceList,
}
|
