Fixed a bug in export settings after reset warning popup

This commit is contained in:
ManeraKai 2022-06-07 19:40:03 +03:00
parent adbfb9a890
commit b2d44f314b
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
2 changed files with 16 additions and 18 deletions

View File

@ -21,26 +21,13 @@ import lbryHelper from "../../assets/javascripts/lbry.js";
window.browser = window.browser || window.chrome;
function openResetWarning() {
return new Promise(resolve => {
browser.storage.local.get(null, r => {
if (r.theme) {
const old = encodeURIComponent(JSON.stringify(r))
browser.tabs.create({ url: browser.runtime.getURL(`/pages/background/reset_warning.html?data=${old}`) });
}
resolve();
})
})
}
browser.runtime.onInstalled.addListener(
async details => {
// if (details.reason == 'install') {
if (details.reason == 'install' || (details.reason == "update" && details.previousVersion != browser.runtime.getManifest().version)) {
if (details.reason == "update") await openResetWarning();
details => {
function initDefaults() {
fetch('/instances/blacklist.json').then(response => response.text()).then(async data => {
browser.storage.local.clear(
() => {
browser.storage.local.set({ cloudflareBlackList: JSON.parse(data).cloudflare },
() => {
browser.storage.local.set({ authenticateBlackList: JSON.parse(data).authenticate },
@ -64,8 +51,19 @@ browser.runtime.onInstalled.addListener(
})
})
});
})
};
// if (details.reason == 'install') {
if (details.reason == 'install' || (details.reason == "update" && details.previousVersion != browser.runtime.getManifest().version)) {
if (details.reason == "update")
browser.storage.local.get(null, r => {
if (r.theme) {
const old = encodeURIComponent(JSON.stringify(r))
browser.tabs.create({ url: browser.runtime.getURL(`/pages/background/reset_warning.html?data=${old}`) });
}
initDefaults();
})
else initDefaults();
}
}
)

View File

@ -1,7 +1,7 @@
let params = new URLSearchParams(location.search);
const resultString = JSON.stringify(
JSON.parse(decodeURIComponent(params.get('data'))),
JSON.parse(params.get('data')),
null,
' '
);