From eb244e93fc0bf47ada97c301156b760507d6bc03 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:50:41 -0700 Subject: [PATCH] Move screenshare stop logic to ringrtc --- 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 a873c11fe..ac106ad36 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 97163afbe..c0b72b300 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,