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

View File

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

View File

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