From 511ccb0a6082e5d5a243d169a9154a933ea7b6c0 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:37:27 -0500 Subject: [PATCH] Move screenshare stop logic to ringrtc Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> --- ts/services/calling.ts | 3 +++ ts/state/ducks/calling.ts | 16 ---------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 755ab65911f..7bc3f82d376 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -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); diff --git a/ts/state/ducks/calling.ts b/ts/state/ducks/calling.ts index 97163afbe9c..c0b72b3002e 100644 --- a/ts/state/ducks/calling.ts +++ b/ts/state/ducks/calling.ts @@ -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,