Move screenshare stop logic to ringrtc

This commit is contained in:
Fedor Indutny 2024-10-10 13:50:41 -07:00 committed by GitHub
parent 833723b58d
commit eb244e93fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 16 deletions

View file

@ -2071,6 +2071,9 @@ export class CallingClass {
maxHeight: REQUESTED_SCREEN_SHARE_HEIGHT,
maxWidth: REQUESTED_SCREEN_SHARE_WIDTH,
mediaStream,
onEnded: () => {
this.reduxInterface?.cancelPresenting();
},
})
);
this.setOutgoingVideo(conversationId, true);

View file

@ -1948,22 +1948,6 @@ function _setPresenting(
callLinkRootKey: rootKey,
});
if (mediaStream != null) {
// If the screen sharing stream is terminated early - stop screen sharing
mediaStream.getVideoTracks()[0]?.addEventListener(
'ended',
() => {
const currentSource = getPresentingSource(getState());
// Verify that the source didn't change while we were waiting.
if (currentSource === sourceToPresent) {
dispatch(cancelPresenting());
}
},
{ once: true }
);
}
dispatch({
type: SET_PRESENTING,
payload: sourceToPresent,