From 0fbeaaf6237b62d5220da0418d05cae4487f29bf Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Mon, 12 Feb 2024 08:55:11 -0800
Subject: feat(settings): settings sync

---
 src/routes/+layout.svelte | 13 +++++++++++++
 1 file changed, 13 insertions(+)

(limited to 'src/routes/+layout.svelte')

diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 835b59f7..64f3d28d 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -23,6 +23,7 @@
 	import Dropdown from '$lib/Dropdown.svelte';
 	import { injectSpeedInsights } from '@vercel/speed-insights/sveltekit';
 	import subtitles from '$lib/Data/Static/subtitles.json';
+	import settingsSyncPulled from '$stores/settingsSyncPulled';
 
 	injectSpeedInsights();
 
@@ -72,6 +73,18 @@
 
 		if (data.user !== undefined && $userIdentity.id === -2)
 			getUserIdentity(data.user).then((h) => userIdentity.set(h));
+
+		if ($settings.settingsSync && $userIdentity.id !== -2)
+			fetch(root(`/api/configuration?id=${$userIdentity.id}`)).then((response) => {
+				if (response.ok)
+					response.json().then((data) => {
+						if (data && data.configuration) {
+							console.log('Pulled remote configuration');
+							settings.set(data.configuration);
+							settingsSyncPulled.set(true);
+						}
+					});
+			});
 	});
 
 	$: {
-- 
cgit v1.2.3

