From 40c0f06c8a7734b241eda0f28cf75f2f45433dc0 Mon Sep 17 00:00:00 2001 From: Benedicte Quimbert Date: Wed, 9 Mar 2022 17:46:11 +0100 Subject: [PATCH] PrivacyShutdownStore modifies constraints according to the user's setting --- .../Components/Menu/SettingsSubMenu.svelte | 28 +++++++++---------- front/src/Stores/MediaStore.ts | 22 +++++++++------ 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/front/src/Components/Menu/SettingsSubMenu.svelte b/front/src/Components/Menu/SettingsSubMenu.svelte index 69857504..67a3073e 100644 --- a/front/src/Components/Menu/SettingsSubMenu.svelte +++ b/front/src/Components/Menu/SettingsSubMenu.svelte @@ -9,19 +9,20 @@ import { isMediaBreakpointUp } from "../../Utils/BreakpointsUtils"; import { audioManagerVolumeStore } from "../../Stores/AudioManagerStore"; - let fullscreen: boolean = localUserStore.getFullscreen(); - let notification: boolean = localUserStore.getNotification() === "granted"; - let forceCowebsiteTrigger: boolean = localUserStore.getForceCowebsiteTrigger(); - let ignoreFollowRequests: boolean = localUserStore.getIgnoreFollowRequests(); - let decreaseAudioPlayerVolumeWhileTalking: boolean = localUserStore.getDecreaseAudioPlayerVolumeWhileTalking(); - let valueGame: number = localUserStore.getGameQualityValue(); - let valueVideo: number = localUserStore.getVideoQualityValue(); - let valueLocale: string = $locale; - let valuePrivacySettings = localUserStore.getPrivacySettings(); - let previewValueGame = valueGame; - let previewValueVideo = valueVideo; - let previewValueLocale = valueLocale; - let previewPrivacySettings = valuePrivacySettings; // TODO: retreive from local storage + let fullscreen: boolean = localUserStore.getFullscreen(); + let notification: boolean = localUserStore.getNotification() === "granted"; + let forceCowebsiteTrigger: boolean = localUserStore.getForceCowebsiteTrigger(); + let ignoreFollowRequests: boolean = localUserStore.getIgnoreFollowRequests(); + let decreaseAudioPlayerVolumeWhileTalking: boolean = localUserStore.getDecreaseAudioPlayerVolumeWhileTalking(); + let valueGame: number = localUserStore.getGameQualityValue(); + let valueVideo: number = localUserStore.getVideoQualityValue(); + let valueLocale: string = $locale; + let valuePrivacySettings = localUserStore.getPrivacySettings(); + + let previewValueGame = valueGame; + let previewValueVideo = valueVideo; + let previewValueLocale = valueLocale; + let previewPrivacySettings = valuePrivacySettings; function saveSetting() { let change = false; @@ -43,7 +44,6 @@ } if (valuePrivacySettings !== previewPrivacySettings) { - console.log(`was: ${previewPrivacySettings} | is: ${valuePrivacySettings}`) localUserStore.setPrivacySettings(valuePrivacySettings); } diff --git a/front/src/Stores/MediaStore.ts b/front/src/Stores/MediaStore.ts index a12469af..f94a3c55 100644 --- a/front/src/Stores/MediaStore.ts +++ b/front/src/Stores/MediaStore.ts @@ -11,7 +11,6 @@ import { peerStore } from "./PeerStore"; import { privacyShutdownStore } from "./PrivacyShutdownStore"; import { MediaStreamConstraintsError } from "./Errors/MediaStreamConstraintsError"; import { SoundMeter } from "../Phaser/Components/SoundMeter"; -import { AudioContext } from "standardized-audio-context"; import { visibilityStore } from "./VisibilityStore"; /** @@ -244,7 +243,6 @@ export const mediaStreamConstraintsStore = derived( cameraEnergySavingStore, isSilentStore, visibilityStore, - //TODO: optionState ], ( [ @@ -257,7 +255,7 @@ export const mediaStreamConstraintsStore = derived( $privacyShutdownStore, $cameraEnergySavingStore, $isSilentStore, - $visibilityStore + $visibilityStore, ], set ) => { @@ -296,7 +294,19 @@ export const mediaStreamConstraintsStore = derived( // Disable webcam for privacy reasons (the game is not visible and we were talking to no one) if ($privacyShutdownStore === true) { - currentVideoConstraint = false; + const userSetting = localUserStore.getPrivacySettings(); + switch (userSetting) { + case "cameraEnabled": + currentAudioConstraint = false; + break; + case "microphoneEnabled": + currentVideoConstraint = false; + break; + case "noneEnabled": + currentVideoConstraint = false; + currentAudioConstraint = false; + break; + } } // Disable webcam for energy reasons (the user is not moving and we are talking to no one) @@ -312,10 +322,6 @@ export const mediaStreamConstraintsStore = derived( currentAudioConstraint = false; } - // if ($visibilityStore === false && $option) { - // - // } - //TODO // Let's make the changes only if the new value is different from the old one. if (