Handle stopping screensharing from native UI
This commit is contained in:
parent
85cf445924
commit
fc7eba772c
2 changed files with 28 additions and 8 deletions
|
@ -104,7 +104,10 @@ import { addCallHistory, reloadCallHistory } from './callHistory';
|
||||||
import { saveDraftRecordingIfNeeded } from './composer';
|
import { saveDraftRecordingIfNeeded } from './composer';
|
||||||
import type { CallHistoryDetails } from '../../types/CallDisposition';
|
import type { CallHistoryDetails } from '../../types/CallDisposition';
|
||||||
import type { StartCallData } from '../../components/ConfirmLeaveCallModal';
|
import type { StartCallData } from '../../components/ConfirmLeaveCallModal';
|
||||||
import { getCallLinksByRoomId } from '../selectors/calling';
|
import {
|
||||||
|
getCallLinksByRoomId,
|
||||||
|
getPresentingSource,
|
||||||
|
} from '../selectors/calling';
|
||||||
import { storageServiceUploadJob } from '../../services/storage';
|
import { storageServiceUploadJob } from '../../services/storage';
|
||||||
import { CallLinkDeleteManager } from '../../jobs/CallLinkDeleteManager';
|
import { CallLinkDeleteManager } from '../../jobs/CallLinkDeleteManager';
|
||||||
import { callLinkRefreshJobQueue } from '../../jobs/callLinkRefreshJobQueue';
|
import { callLinkRefreshJobQueue } from '../../jobs/callLinkRefreshJobQueue';
|
||||||
|
@ -1332,15 +1335,9 @@ function getPresentingSources(): ThunkAction<
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onMediaStream(mediaStream) {
|
onMediaStream(mediaStream) {
|
||||||
let presentingSource: PresentedSource | undefined;
|
|
||||||
const { activeCallState } = getState().calling;
|
|
||||||
if (activeCallState?.state === 'Active') {
|
|
||||||
({ presentingSource } = activeCallState);
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
_setPresenting(
|
_setPresenting(
|
||||||
presentingSource || {
|
getPresentingSource(getState()) || {
|
||||||
id: 'media-stream',
|
id: 'media-stream',
|
||||||
name: '',
|
name: '',
|
||||||
},
|
},
|
||||||
|
@ -1947,6 +1944,22 @@ function _setPresenting(
|
||||||
callLinkRootKey: rootKey,
|
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({
|
dispatch({
|
||||||
type: SET_PRESENTING,
|
type: SET_PRESENTING,
|
||||||
payload: sourceToPresent,
|
payload: sourceToPresent,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import type {
|
||||||
ActiveCallStateType,
|
ActiveCallStateType,
|
||||||
} from '../ducks/calling';
|
} from '../ducks/calling';
|
||||||
import { getIncomingCall as getIncomingCallHelper } from '../ducks/callingHelpers';
|
import { getIncomingCall as getIncomingCallHelper } from '../ducks/callingHelpers';
|
||||||
|
import type { PresentedSource } from '../../types/Calling';
|
||||||
import { CallMode } from '../../types/CallDisposition';
|
import { CallMode } from '../../types/CallDisposition';
|
||||||
import type { CallLinkType } from '../../types/CallLink';
|
import type { CallLinkType } from '../../types/CallLink';
|
||||||
import { getUserACI } from './user';
|
import { getUserACI } from './user';
|
||||||
|
@ -166,3 +167,9 @@ export const areAnyCallsActiveOrRinging = createSelector(
|
||||||
getIncomingCall,
|
getIncomingCall,
|
||||||
(activeCall, incomingCall): boolean => Boolean(activeCall || incomingCall)
|
(activeCall, incomingCall): boolean => Boolean(activeCall || incomingCall)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const getPresentingSource = createSelector(
|
||||||
|
getActiveCallState,
|
||||||
|
(activeCallState): PresentedSource | undefined =>
|
||||||
|
activeCallState?.presentingSource
|
||||||
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue