diff options
| author | Fuwn <[email protected]> | 2024-02-12 09:27:30 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-02-12 09:27:30 -0800 |
| commit | 81e6a9e431f9c6a109d7f4052f6af9a6d5bc6498 (patch) | |
| tree | 488e33511a9ac93f0ec40fa00ae2d75ffb082355 /src/routes/settings | |
| parent | feat(settings): localise settings sync (diff) | |
| download | due.moe-81e6a9e431f9c6a109d7f4052f6af9a6d5bc6498.tar.xz due.moe-81e6a9e431f9c6a109d7f4052f6af9a6d5bc6498.zip | |
refactor(settings): move settings sync to component
Diffstat (limited to 'src/routes/settings')
| -rw-r--r-- | src/routes/settings/+page.svelte | 82 |
1 files changed, 2 insertions, 80 deletions
diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte index b682cb39..45b55ad4 100644 --- a/src/routes/settings/+page.svelte +++ b/src/routes/settings/+page.svelte @@ -16,8 +16,7 @@ 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'; + import SettingSync from '$lib/Settings/Categories/SettingSync.svelte'; export let data; @@ -69,84 +68,7 @@ <LogInRestricted /> {:else} <Category title={$locale().settings.settingsSync.title} id="sync" open={false}> - {#if !$settings.settingsSync} - <button - on:click={() => { - $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' - }) - ); - }); - } - }); - } - }); - }} - > - {$locale().settings.settingsSync.buttons.pull.title} - </button> - <SettingHint lineBreak> - {$locale().settings.settingsSync.buttons.pull.hint} - </SettingHint> - <p /> - <button - on:click={() => { - $settings.settingsSync = true; - - fetch(root(`/api/configuration`), { - method: 'PUT', - body: JSON.stringify($settings) - }).then((response) => { - if (response.ok) - addNotification( - options({ - heading: 'Settings Sync', - description: 'Pushed local configuration to remote' - }) - ); - }); - }} - > - {$locale().settings.settingsSync.buttons.push.title} - </button> - <SettingHint lineBreak> - {$locale().settings.settingsSync.buttons.push.hint} - </SettingHint> - {:else} - <button - on:click={() => { - $settings.settingsSync = false; - - addNotification( - options({ - heading: 'Settings sync disabled' - }) - ); - }} - > - {$locale().settings.settingsSync.buttons.disable} - </button> - {/if} + <SettingSync /> </Category> <Category title={$locale().settings.rssFeeds.title} id="feeds"> <button |