mirror of
https://github.com/vector-im/element-call.git
synced 2026-04-03 07:10:26 +00:00
Fix mute button not being in sync with actual video/audio feed.
This happens if we toggle the button while waiting for updating the stream. It is prohibited by checking if the stream state is in sync after the update is done. Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
@@ -137,20 +137,32 @@ export function useLiveKit(
|
||||
// and setting tracks to be enabled during this time causes errors.
|
||||
if (room !== undefined && connectionState === ConnectionState.Connected) {
|
||||
const participant = room.localParticipant;
|
||||
if (participant.isMicrophoneEnabled !== muteStates.audio.enabled) {
|
||||
participant
|
||||
.setMicrophoneEnabled(muteStates.audio.enabled)
|
||||
.catch((e) =>
|
||||
logger.error("Failed to sync audio mute state with LiveKit", e)
|
||||
);
|
||||
}
|
||||
if (participant.isCameraEnabled !== muteStates.video.enabled) {
|
||||
participant
|
||||
.setCameraEnabled(muteStates.video.enabled)
|
||||
.catch((e) =>
|
||||
logger.error("Failed to sync video mute state with LiveKit", e)
|
||||
);
|
||||
}
|
||||
|
||||
const syncMuteStateAudio = () => {
|
||||
if (participant.isCameraEnabled !== muteStates.video.enabled) {
|
||||
participant
|
||||
.setCameraEnabled(muteStates.video.enabled)
|
||||
.catch((e) =>
|
||||
logger.error("Failed to sync video mute state with LiveKit", e)
|
||||
)
|
||||
// Run the check recursively. Because the user can update the state (presses mute button)
|
||||
// while the device is enabling itself we need to check after we are done if its still in sync.
|
||||
.then(() => syncMuteStateAudio());
|
||||
}
|
||||
};
|
||||
const syncMuteStateVideo = () => {
|
||||
if (participant.isMicrophoneEnabled !== muteStates.audio.enabled) {
|
||||
participant
|
||||
.setMicrophoneEnabled(muteStates.audio.enabled)
|
||||
.catch((e) =>
|
||||
logger.error("Failed to sync audio mute state with LiveKit", e)
|
||||
)
|
||||
// see above
|
||||
.then(() => syncMuteStateVideo());
|
||||
}
|
||||
};
|
||||
syncMuteStateAudio();
|
||||
syncMuteStateVideo();
|
||||
}
|
||||
}, [room, muteStates, connectionState]);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ export function enterRTCSession(rtcSession: MatrixRTCSession) {
|
||||
// have started tracking by the time calls start getting created.
|
||||
//groupCallOTelMembership?.onJoinCall();
|
||||
|
||||
// right now we asume everything is a room-scoped call
|
||||
// right now we assume everything is a room-scoped call
|
||||
const livekitAlias = rtcSession.room.roomId;
|
||||
|
||||
rtcSession.joinRoomSession([makeFocus(livekitAlias)]);
|
||||
|
||||
Reference in New Issue
Block a user