Show tiles for members we're trying to connect to
This should help give more context on what's going wrong in splitbrain scenarios. If users leave calls uncleanly, their tile will remain in until their member event times out, which will be an hour from when they joined the call. See https://github.com/vector-im/element-call/issues/639. Part of https://github.com/vector-im/element-call/issues/616
This commit is contained in:
@@ -35,21 +35,31 @@ declare global {
|
||||
export const useMediaStreamTrackCount = (
|
||||
stream: MediaStream
|
||||
): [number, number] => {
|
||||
const latestAudioTrackCount = stream ? stream.getAudioTracks().length : 0;
|
||||
const latestVideoTrackCount = stream ? stream.getVideoTracks().length : 0;
|
||||
|
||||
const [audioTrackCount, setAudioTrackCount] = useState(
|
||||
stream.getAudioTracks().length
|
||||
stream ? stream.getAudioTracks().length : 0
|
||||
);
|
||||
const [videoTrackCount, setVideoTrackCount] = useState(
|
||||
stream.getVideoTracks().length
|
||||
stream ? stream.getVideoTracks().length : 0
|
||||
);
|
||||
|
||||
const tracksChanged = useCallback(() => {
|
||||
setAudioTrackCount(stream.getAudioTracks().length);
|
||||
setVideoTrackCount(stream.getVideoTracks().length);
|
||||
setAudioTrackCount(stream ? stream.getAudioTracks().length : 0);
|
||||
setVideoTrackCount(stream ? stream.getVideoTracks().length : 0);
|
||||
}, [stream]);
|
||||
|
||||
useEventTarget(stream, "addtrack", tracksChanged);
|
||||
useEventTarget(stream, "removetrack", tracksChanged);
|
||||
|
||||
if (
|
||||
latestAudioTrackCount !== audioTrackCount ||
|
||||
latestVideoTrackCount !== videoTrackCount
|
||||
) {
|
||||
tracksChanged();
|
||||
}
|
||||
|
||||
return [audioTrackCount, videoTrackCount];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user