diff options
| author | Fuwn <[email protected]> | 2024-02-12 08:55:11 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-02-12 08:55:11 -0800 |
| commit | 0fbeaaf6237b62d5220da0418d05cae4487f29bf (patch) | |
| tree | 036ea9187a07d860e0d65373a8ee5a3137b758f5 /src/routes/settings | |
| parent | fix(anime): new list on new episode (diff) | |
| download | due.moe-0fbeaaf6237b62d5220da0418d05cae4487f29bf.tar.xz due.moe-0fbeaaf6237b62d5220da0418d05cae4487f29bf.zip | |
feat(settings): settings sync
Diffstat (limited to 'src/routes/settings')
| -rw-r--r-- | src/routes/settings/+page.svelte | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte index 03dcedde..342e73a3 100644 --- a/src/routes/settings/+page.svelte +++ b/src/routes/settings/+page.svelte @@ -16,6 +16,8 @@ import locale from '$stores/locale.js'; import settings from '$stores/settings'; import LogInRestricted from '$lib/Error/LogInRestricted.svelte'; + import root from '$lib/Utility/root'; + import identity from '$stores/identity.js'; export let data; @@ -66,6 +68,56 @@ {#if data.user === undefined} <LogInRestricted /> {:else} + <button + on:click={() => { + if (!$settings.settingsSync) { + $settings.settingsSync = true; + + fetch(root(`/api/configuration?id=${$identity.id}`)).then((response) => { + if (response.ok) { + response.json().then((data) => { + if (data && data.configuration) { + $settings = data.configuration; + + addNotification( + options({ + heading: 'Pulled remote configuration' + }) + ); + } else { + fetch(root(`/api/configuration`), { + method: 'PUT', + body: JSON.stringify($settings) + }).then((response) => { + if (response.ok) + addNotification( + options({ + heading: 'Created remote configuration' + }) + ); + }); + } + }); + } + }); + } else { + $settings.settingsSync = false; + + addNotification( + options({ + heading: 'Disabled settings sync' + }) + ); + } + }} + > + {$settings.settingsSync ? 'Disable' : 'Enable'} Settings Sync & {$settings.settingsSync + ? 'Keep Local Configuration' + : 'Pull Remote Configuration'} + </button> + + <p /> + <Category title={$locale().settings.rssFeeds.title} id="feeds"> <button on:click={() => { |