From f8d06cf18b3070d4c91ca1817f83d14b0889b1f2 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Tue, 23 Jul 2024 18:17:38 +0000 Subject: [PATCH] web/settings: settings import/export --- .../settings/TransferSettings.svelte | 68 +++++++++++++++++++ web/src/lib/state/settings.ts | 5 ++ web/src/routes/settings/advanced/+page.svelte | 4 +- 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 web/src/components/settings/TransferSettings.svelte diff --git a/web/src/components/settings/TransferSettings.svelte b/web/src/components/settings/TransferSettings.svelte new file mode 100644 index 00000000..d73bf6b7 --- /dev/null +++ b/web/src/components/settings/TransferSettings.svelte @@ -0,0 +1,68 @@ + + +
+ + import + + + export + +
+ + \ No newline at end of file diff --git a/web/src/lib/state/settings.ts b/web/src/lib/state/settings.ts index e19c50bb..231d21b3 100644 --- a/web/src/lib/state/settings.ts +++ b/web/src/lib/state/settings.ts @@ -41,6 +41,7 @@ const migrate = (settings: AllPartialSettingsWithSchema): PartialSettings => { }, settings as AllPartialSettingsWithSchema); } + const loadFromStorage = () => { const settings = localStorage.getItem('settings'); if (!settings) { @@ -52,6 +53,10 @@ const loadFromStorage = () => { return {}; } + return loadFromString(settings); +} + +export const loadFromString = (settings: string) => { const parsed = JSON.parse(settings) as AllPartialSettingsWithSchema; if (parsed.schemaVersion < defaultSettings.schemaVersion) { return migrate(parsed); diff --git a/web/src/routes/settings/advanced/+page.svelte b/web/src/routes/settings/advanced/+page.svelte index 6ac2b73e..3d7e732d 100644 --- a/web/src/routes/settings/advanced/+page.svelte +++ b/web/src/routes/settings/advanced/+page.svelte @@ -1,9 +1,10 @@ - @@ -16,5 +17,6 @@ +