aboutsummaryrefslogtreecommitdiff
path: root/src/stores/settings.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/settings.ts')
-rw-r--r--src/stores/settings.ts18
1 files changed, 16 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;