PrivacyShutdownStore modifies constraints according to the user's setting

This commit is contained in:
Benedicte Quimbert 2022-03-09 17:46:11 +01:00
parent 85f3a1a9c8
commit 40c0f06c8a
2 changed files with 28 additions and 22 deletions

View File

@ -9,19 +9,20 @@
import { isMediaBreakpointUp } from "../../Utils/BreakpointsUtils"; import { isMediaBreakpointUp } from "../../Utils/BreakpointsUtils";
import { audioManagerVolumeStore } from "../../Stores/AudioManagerStore"; import { audioManagerVolumeStore } from "../../Stores/AudioManagerStore";
let fullscreen: boolean = localUserStore.getFullscreen(); let fullscreen: boolean = localUserStore.getFullscreen();
let notification: boolean = localUserStore.getNotification() === "granted"; let notification: boolean = localUserStore.getNotification() === "granted";
let forceCowebsiteTrigger: boolean = localUserStore.getForceCowebsiteTrigger(); let forceCowebsiteTrigger: boolean = localUserStore.getForceCowebsiteTrigger();
let ignoreFollowRequests: boolean = localUserStore.getIgnoreFollowRequests(); let ignoreFollowRequests: boolean = localUserStore.getIgnoreFollowRequests();
let decreaseAudioPlayerVolumeWhileTalking: boolean = localUserStore.getDecreaseAudioPlayerVolumeWhileTalking(); let decreaseAudioPlayerVolumeWhileTalking: boolean = localUserStore.getDecreaseAudioPlayerVolumeWhileTalking();
let valueGame: number = localUserStore.getGameQualityValue(); let valueGame: number = localUserStore.getGameQualityValue();
let valueVideo: number = localUserStore.getVideoQualityValue(); let valueVideo: number = localUserStore.getVideoQualityValue();
let valueLocale: string = $locale; let valueLocale: string = $locale;
let valuePrivacySettings = localUserStore.getPrivacySettings(); let valuePrivacySettings = localUserStore.getPrivacySettings();
let previewValueGame = valueGame;
let previewValueVideo = valueVideo; let previewValueGame = valueGame;
let previewValueLocale = valueLocale; let previewValueVideo = valueVideo;
let previewPrivacySettings = valuePrivacySettings; // TODO: retreive from local storage let previewValueLocale = valueLocale;
let previewPrivacySettings = valuePrivacySettings;
function saveSetting() { function saveSetting() {
let change = false; let change = false;
@ -43,7 +44,6 @@
} }
if (valuePrivacySettings !== previewPrivacySettings) { if (valuePrivacySettings !== previewPrivacySettings) {
console.log(`was: ${previewPrivacySettings} | is: ${valuePrivacySettings}`)
localUserStore.setPrivacySettings(valuePrivacySettings); localUserStore.setPrivacySettings(valuePrivacySettings);
} }

View File

@ -11,7 +11,6 @@ import { peerStore } from "./PeerStore";
import { privacyShutdownStore } from "./PrivacyShutdownStore"; import { privacyShutdownStore } from "./PrivacyShutdownStore";
import { MediaStreamConstraintsError } from "./Errors/MediaStreamConstraintsError"; import { MediaStreamConstraintsError } from "./Errors/MediaStreamConstraintsError";
import { SoundMeter } from "../Phaser/Components/SoundMeter"; import { SoundMeter } from "../Phaser/Components/SoundMeter";
import { AudioContext } from "standardized-audio-context";
import { visibilityStore } from "./VisibilityStore"; import { visibilityStore } from "./VisibilityStore";
/** /**
@ -244,7 +243,6 @@ export const mediaStreamConstraintsStore = derived(
cameraEnergySavingStore, cameraEnergySavingStore,
isSilentStore, isSilentStore,
visibilityStore, visibilityStore,
//TODO: optionState
], ],
( (
[ [
@ -257,7 +255,7 @@ export const mediaStreamConstraintsStore = derived(
$privacyShutdownStore, $privacyShutdownStore,
$cameraEnergySavingStore, $cameraEnergySavingStore,
$isSilentStore, $isSilentStore,
$visibilityStore $visibilityStore,
], ],
set 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) // Disable webcam for privacy reasons (the game is not visible and we were talking to no one)
if ($privacyShutdownStore === true) { 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) // 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; currentAudioConstraint = false;
} }
// if ($visibilityStore === false && $option) {
//
// }
//TODO
// Let's make the changes only if the new value is different from the old one. // Let's make the changes only if the new value is different from the old one.
if ( if (