diff --git a/front/src/Components/Menu/SettingsSubMenu.svelte b/front/src/Components/Menu/SettingsSubMenu.svelte index d5b40822..d5bcab56 100644 --- a/front/src/Components/Menu/SettingsSubMenu.svelte +++ b/front/src/Components/Menu/SettingsSubMenu.svelte @@ -8,243 +8,275 @@ import { displayableLocales, setCurrentLocale } from "../../i18n/locales"; import { isMediaBreakpointUp } from "../../Utils/BreakpointsUtils"; - let fullscreen: boolean = localUserStore.getFullscreen(); - let notification: boolean = localUserStore.getNotification() === "granted"; - let forceCowebsiteTrigger: boolean = localUserStore.getForceCowebsiteTrigger(); - let ignoreFollowRequests: boolean = localUserStore.getIgnoreFollowRequests(); - let valueGame: number = localUserStore.getGameQualityValue(); - let valueVideo: number = localUserStore.getVideoQualityValue(); - let valueLocale: string = $locale; - let previewValueGame = valueGame; - let previewValueVideo = valueVideo; - let previewValueLocale = valueLocale; + let fullscreen: boolean = localUserStore.getFullscreen(); + let notification: boolean = localUserStore.getNotification() === "granted"; + let forceCowebsiteTrigger: boolean = localUserStore.getForceCowebsiteTrigger(); + let ignoreFollowRequests: boolean = localUserStore.getIgnoreFollowRequests(); + let valueGame: number = localUserStore.getGameQualityValue(); + let valueVideo: number = localUserStore.getVideoQualityValue(); + let valueLocale: string = $locale; + let valuePrivacySettings = localUserStore.getPrivacySettings(); - function saveSetting() { - let change = false; + let previewValueGame = valueGame; + let previewValueVideo = valueVideo; + let previewValueLocale = valueLocale; + let previewPrivacySettings = valuePrivacySettings; // TODO: retreive from local storage - if (valueLocale !== previewValueLocale) { - previewValueLocale = valueLocale; - setCurrentLocale(valueLocale as Locales); - } + function saveSetting() { + let change = false; - if (valueVideo !== previewValueVideo) { - previewValueVideo = valueVideo; - videoConstraintStore.setFrameRate(valueVideo); - } - - if (valueGame !== previewValueGame) { - previewValueGame = valueGame; - localUserStore.setGameQualityValue(valueGame); - change = true; - } - - if (change) { - window.location.reload(); - } - - closeMenu(); + if (valueLocale !== previewValueLocale) { + previewValueLocale = valueLocale; + setCurrentLocale(valueLocale as Locales); } - function changeFullscreen() { - const body = HtmlUtils.querySelectorOrFail("body"); - if (body) { - if (document.fullscreenElement !== null && !fullscreen) { - document.exitFullscreen().catch((e) => console.error(e)); - } else { - body.requestFullscreen().catch((e) => console.error(e)); - } - localUserStore.setFullscreen(fullscreen); - } + if (valueVideo !== previewValueVideo) { + previewValueVideo = valueVideo; + videoConstraintStore.setFrameRate(valueVideo); } - function changeNotification() { - if (Notification.permission === "granted") { + if (valueGame !== previewValueGame) { + previewValueGame = valueGame; + localUserStore.setGameQualityValue(valueGame); + change = true; + } + + if (valuePrivacySettings !== previewPrivacySettings) { + console.log(`was: ${previewPrivacySettings} | is: ${valuePrivacySettings}`) + localUserStore.setPrivacySettings(valuePrivacySettings); + } + + if (change) { + window.location.reload(); + } + + closeMenu(); + } + + function changeFullscreen() { + const body = HtmlUtils.querySelectorOrFail("body"); + if (body) { + if (document.fullscreenElement !== null && !fullscreen) { + document.exitFullscreen().catch((e) => console.error(e)); + } else { + body.requestFullscreen().catch((e) => console.error(e)); + } + localUserStore.setFullscreen(fullscreen); + } + } + + function changeNotification() { + if (Notification.permission === "granted") { + localUserStore.setNotification(notification ? "granted" : "denied"); + } else { + Notification.requestPermission() + .then((response) => { + if (response === "granted") { localUserStore.setNotification(notification ? "granted" : "denied"); - } else { - Notification.requestPermission() - .then((response) => { - if (response === "granted") { - localUserStore.setNotification(notification ? "granted" : "denied"); - } else { - localUserStore.setNotification("denied"); - notification = false; - } - }) - .catch((e) => console.error(e)); - } + } else { + localUserStore.setNotification("denied"); + notification = false; + } + }) + .catch((e) => console.error(e)); } + } - function changeForceCowebsiteTrigger() { - localUserStore.setForceCowebsiteTrigger(forceCowebsiteTrigger); - } + function changeForceCowebsiteTrigger() { + localUserStore.setForceCowebsiteTrigger(forceCowebsiteTrigger); + } - function changeIgnoreFollowRequests() { - localUserStore.setIgnoreFollowRequests(ignoreFollowRequests); - } + function changeIgnoreFollowRequests() { + localUserStore.setIgnoreFollowRequests(ignoreFollowRequests); + } - function closeMenu() { - menuVisiblilityStore.set(false); - } + function closeMenu() { + menuVisiblilityStore.set(false); + } - const isMobile = isMediaBreakpointUp("md"); + const isMobile = isMediaBreakpointUp("md");
{$LL.menu.settings.save.warning()}
- +{$LL.menu.settings.privacySettings.explaination()}
+{$LL.menu.settings.save.warning()}
+ +