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/stores | |
| 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/stores')
| -rw-r--r-- | src/stores/settings.ts | 18 | ||||
| -rw-r--r-- | src/stores/settingsSyncPulled.ts | 5 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/stores/settings.ts b/src/stores/settings.ts index 5c27c516..e92d4150 100644 --- a/src/stores/settings.ts +++ b/src/stores/settings.ts @@ -1,5 +1,7 @@ import { browser } from '$app/environment'; -import { writable } from 'svelte/store'; +import root from '$lib/Utility/root'; +import { get, writable } from 'svelte/store'; +import settingsSyncPulled from './settingsSyncPulled'; export interface Settings { cacheMangaMinutes: number; @@ -48,6 +50,7 @@ export interface Settings { displayScheduleListMode: boolean; displayLanguage: 'en' | 'ja'; displayDisableLastActivityWarning: boolean; + settingsSync: boolean; } const defaultSettings: Settings = { @@ -91,7 +94,10 @@ const defaultSettings: Settings = { // Cache cacheMangaMinutes: 120, - cacheMinutes: 30 + cacheMinutes: 30, + + // Sync + settingsSync: false }; const createStore = () => { @@ -134,6 +140,14 @@ const settings = createStore(); settings.subscribe((value) => { if (browser) localStorage.setItem('settings', JSON.stringify(value)); + + if (value.settingsSync && get(settingsSyncPulled) == true) + fetch(root(`/api/configuration`), { + method: 'PUT', + body: JSON.stringify(value) + }).then((response) => { + if (response.ok) console.log('Pushed local configuration'); + }); }); export default settings; diff --git a/src/stores/settingsSyncPulled.ts b/src/stores/settingsSyncPulled.ts new file mode 100644 index 00000000..1e9c3333 --- /dev/null +++ b/src/stores/settingsSyncPulled.ts @@ -0,0 +1,5 @@ +import { writable } from 'svelte/store'; + +const settingsSyncPulled = writable<boolean>(false); + +export default settingsSyncPulled; |