From ed0c90ec3de1fa5fa8f7ebc138d62174eb07b363 Mon Sep 17 00:00:00 2001 From: ManeraKai Date: Sat, 27 Jul 2024 12:11:54 +0300 Subject: [PATCH] Cleaned code --- src/pages/components/Button.svelte | 2 +- src/pages/components/Input.svelte | 2 +- src/pages/components/Row.svelte | 2 +- src/pages/options_src/General/General.svelte | 6 ++-- .../General/SettingsButtons.svelte | 34 ++++++------------- src/pages/options_src/Sidebar.svelte | 6 ++-- 6 files changed, 18 insertions(+), 34 deletions(-) diff --git a/src/pages/components/Button.svelte b/src/pages/components/Button.svelte index 3405c2e..8836b47 100644 --- a/src/pages/components/Button.svelte +++ b/src/pages/components/Button.svelte @@ -1,4 +1,4 @@ - diff --git a/src/pages/components/Input.svelte b/src/pages/components/Input.svelte index 97a47e6..59e584d 100644 --- a/src/pages/components/Input.svelte +++ b/src/pages/components/Input.svelte @@ -3,7 +3,7 @@ +
diff --git a/src/pages/options_src/General/General.svelte b/src/pages/options_src/General/General.svelte index 732ad83..37c38a0 100644 --- a/src/pages/options_src/General/General.svelte +++ b/src/pages/options_src/General/General.svelte @@ -38,7 +38,6 @@ _options.theme = e.target.options[e.target.options.selectedIndex].value options.set(_options) }} - ariaLabel="select theme" /> @@ -55,7 +54,6 @@ _options.fetchInstances = e.target.options[e.target.options.selectedIndex].value options.set(_options) }} - ariaLabel={"Select fetch public instances"} /> @@ -75,7 +73,7 @@ - + - + diff --git a/src/pages/options_src/General/SettingsButtons.svelte b/src/pages/options_src/General/SettingsButtons.svelte index 3ea46a2..2f57419 100644 --- a/src/pages/options_src/General/SettingsButtons.svelte +++ b/src/pages/options_src/General/SettingsButtons.svelte @@ -14,24 +14,18 @@ const unsubscribe = options.subscribe(val => (_options = val)) onDestroy(unsubscribe) - let disableButtons = false - let importSettingsInput let importSettingsFiles $: if (importSettingsFiles) { - disableButtons = true const reader = new FileReader() reader.readAsText(importSettingsFiles[0]) reader.onload = async () => { const data = JSON.parse(reader.result) if ("theme" in data && data.version == browser.runtime.getManifest().version) { browser.storage.local.clear(async () => { - console.log("clearing") options.set(data) - disableButtons = false }) } else { - console.log("incompatible settings") alert("Incompatible settings") } } @@ -42,26 +36,21 @@ } async function exportSettings() { - disableButtons = true _options.version = browser.runtime.getManifest().version const resultString = JSON.stringify(_options, null, " ") const anchor = document.createElement("a") anchor.href = "data:application/json;base64," + btoa(resultString) anchor.download = `libredirect-settings-v${_options.version}.json` anchor.click() - disableButtons = false } async function exportSettingsSync() { - disableButtons = true _options.version = browser.runtime.getManifest().version await servicesHelper.initDefaults() browser.storage.sync.set({ options: _options }) - disableButtons = false } async function importSettingsSync() { - disableButtons = true browser.storage.sync.get({ options }, r => { const optionsSync = r.options if (optionsSync.version == browser.runtime.getManifest().version) { @@ -69,24 +58,21 @@ } else { alert("Error") } - disableButtons = false }) } async function resetSettings() { - disableButtons = true browser.storage.local.clear(async () => { await servicesHelper.initDefaults() options.set(await utils.getOptions()) - disableButtons = false }) }
- - - - -
diff --git a/src/pages/options_src/Sidebar.svelte b/src/pages/options_src/Sidebar.svelte index fb515f5..97780b1 100644 --- a/src/pages/options_src/Sidebar.svelte +++ b/src/pages/options_src/Sidebar.svelte @@ -10,15 +10,15 @@