listen to silentStore instead of statusStore when no other statuses are needed

This commit is contained in:
Piotr 'pwh' Hanusiak 2022-04-21 09:30:48 +02:00
parent c6d445bd97
commit 76672789cf
3 changed files with 9 additions and 12 deletions

View File

@ -1,7 +1,6 @@
import { availabilityStatusStore, requestedCameraState, requestedMicrophoneState } from "../../Stores/MediaStore";
import { requestedCameraState, requestedMicrophoneState, silentStore } from "../../Stores/MediaStore";
import { get } from "svelte/store";
import { WorkAdventureDesktopApi } from "@wa-preload-app";
import { AvailabilityStatus } from "../../Messages/ts-proto-generated/protos/messages";
declare global {
interface Window {
@ -37,8 +36,8 @@ class DesktopApi {
}
});
availabilityStatusStore.subscribe((status) => {
this.isSilent = status === AvailabilityStatus.SILENT;
silentStore.subscribe((silent) => {
this.isSilent = silent;
});
}
}

View File

@ -1,6 +1,6 @@
<script lang="ts">
import { requestedScreenSharingState, screenSharingAvailableStore } from "../Stores/ScreenSharingStore";
import { availabilityStatusStore, requestedCameraState, requestedMicrophoneState } from "../Stores/MediaStore";
import { requestedCameraState, requestedMicrophoneState, silentStore } from "../Stores/MediaStore";
import monitorImg from "./images/monitor.svg";
import monitorCloseImg from "./images/monitor-close.svg";
import cinemaImg from "./images/cinema.svg";
@ -18,7 +18,6 @@
import { followRoleStore, followStateStore, followUsersStore } from "../Stores/FollowStore";
import { gameManager } from "../Phaser/Game/GameManager";
import { currentPlayerGroupLockStateStore } from "../Stores/CurrentPlayerGroupStore";
import { AvailabilityStatus } from "../Messages/ts-proto-generated/protos/messages";
const gameScene = gameManager.getCurrentGameScene();
@ -78,8 +77,8 @@
}
let isSilent: boolean;
const unsubscribeIsSilent = availabilityStatusStore.subscribe((status) => {
isSilent = status === AvailabilityStatus.SILENT;
const unsubscribeIsSilent = silentStore.subscribe((silent) => {
isSilent = silent;
});
onDestroy(unsubscribeIsSilent);
</script>

View File

@ -1,11 +1,10 @@
<script lang="ts">
import { availabilityStatusStore, localVolumeStore, obtainedMediaConstraintStore } from "../Stores/MediaStore";
import { localVolumeStore, obtainedMediaConstraintStore, silentStore } from "../Stores/MediaStore";
import { localStreamStore } from "../Stores/MediaStore";
import SoundMeterWidget from "./SoundMeterWidget.svelte";
import { onDestroy, onMount } from "svelte";
import { srcObject } from "./Video/utils";
import LL from "../i18n/i18n-svelte";
import { AvailabilityStatus } from "../Messages/ts-proto-generated/protos/messages";
let stream: MediaStream | null;
@ -22,8 +21,8 @@
});
let isSilent: boolean;
const unsubscribeIsSilent = availabilityStatusStore.subscribe((status) => {
isSilent = status === AvailabilityStatus.SILENT;
const unsubscribeIsSilent = silentStore.subscribe((silent) => {
isSilent = silent;
});
let cameraContainer: HTMLDivElement;