Fixing comparison of constraints state

Comparison was broken because we were not performing a deep comparison.
This commit is contained in:
David Négrier 2022-04-11 18:50:58 +02:00
parent 003bc86262
commit a99815a1b4
2 changed files with 5 additions and 5 deletions

View File

@ -43,6 +43,7 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"deep-copy-ts": "^0.5.0", "deep-copy-ts": "^0.5.0",
"easystarjs": "^0.4.4", "easystarjs": "^0.4.4",
"fast-deep-equal": "^3.1.3",
"generic-type-guard": "^3.4.2", "generic-type-guard": "^3.4.2",
"google-protobuf": "^3.13.0", "google-protobuf": "^3.13.0",
"phaser": "^3.54.0", "phaser": "^3.54.0",

View File

@ -12,6 +12,7 @@ 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 { visibilityStore } from "./VisibilityStore"; import { visibilityStore } from "./VisibilityStore";
import deepEqual from "fast-deep-equal";
/** /**
* A store that contains the camera state requested by the user (on or off). * A store that contains the camera state requested by the user (on or off).
@ -242,7 +243,6 @@ export const mediaStreamConstraintsStore = derived(
privacyShutdownStore, privacyShutdownStore,
cameraEnergySavingStore, cameraEnergySavingStore,
isSilentStore, isSilentStore,
visibilityStore,
], ],
( (
[ [
@ -255,7 +255,6 @@ export const mediaStreamConstraintsStore = derived(
$privacyShutdownStore, $privacyShutdownStore,
$cameraEnergySavingStore, $cameraEnergySavingStore,
$isSilentStore, $isSilentStore,
$visibilityStore,
], ],
set set
) => { ) => {
@ -317,10 +316,10 @@ export const mediaStreamConstraintsStore = derived(
currentAudioConstraint = false; currentAudioConstraint = false;
} }
// 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.tile
if ( if (
previousComputedVideoConstraint != currentVideoConstraint || !deepEqual(previousComputedVideoConstraint, currentVideoConstraint) ||
previousComputedAudioConstraint != currentAudioConstraint !deepEqual(previousComputedAudioConstraint, currentAudioConstraint)
) { ) {
previousComputedVideoConstraint = currentVideoConstraint; previousComputedVideoConstraint = currentVideoConstraint;
previousComputedAudioConstraint = currentAudioConstraint; previousComputedAudioConstraint = currentAudioConstraint;