Send call messages with conversationJobQueue
Co-authored-by: trevor-signal <trevor@signal.org>
This commit is contained in:
parent
72169820eb
commit
783c71999a
18 changed files with 457 additions and 392 deletions
|
@ -152,7 +152,6 @@ export type ActiveCallStateType = {
|
|||
pip: boolean;
|
||||
presentingSource?: PresentedSource;
|
||||
presentingSourcesAvailable?: Array<PresentableSource>;
|
||||
safetyNumberChangedAcis: Array<AciString>;
|
||||
settingsDialogOpen: boolean;
|
||||
showNeedsScreenRecordingPermissionsWarning?: boolean;
|
||||
showParticipantsList: boolean;
|
||||
|
@ -249,14 +248,6 @@ type HangUpActionPayloadType = ReadonlyDeep<{
|
|||
conversationId: string;
|
||||
}>;
|
||||
|
||||
type KeyChangedType = ReadonlyDeep<{
|
||||
aci: AciString;
|
||||
}>;
|
||||
|
||||
export type KeyChangeOkType = ReadonlyDeep<{
|
||||
conversationId: string;
|
||||
}>;
|
||||
|
||||
export type IncomingDirectCallType = ReadonlyDeep<{
|
||||
conversationId: string;
|
||||
isVideoCall: boolean;
|
||||
|
@ -579,8 +570,6 @@ const GROUP_CALL_REACTIONS_EXPIRED = 'calling/GROUP_CALL_REACTIONS_EXPIRED';
|
|||
const HANG_UP = 'calling/HANG_UP';
|
||||
const INCOMING_DIRECT_CALL = 'calling/INCOMING_DIRECT_CALL';
|
||||
const INCOMING_GROUP_CALL = 'calling/INCOMING_GROUP_CALL';
|
||||
const MARK_CALL_TRUSTED = 'calling/MARK_CALL_TRUSTED';
|
||||
const MARK_CALL_UNTRUSTED = 'calling/MARK_CALL_UNTRUSTED';
|
||||
const OUTGOING_CALL = 'calling/OUTGOING_CALL';
|
||||
const PEEK_GROUP_CALL_FULFILLED = 'calling/PEEK_GROUP_CALL_FULFILLED';
|
||||
const RAISE_HAND_GROUP_CALL = 'calling/RAISE_HAND_GROUP_CALL';
|
||||
|
@ -725,19 +714,6 @@ type IncomingGroupCallActionType = ReadonlyDeep<{
|
|||
payload: IncomingGroupCallType;
|
||||
}>;
|
||||
|
||||
// eslint-disable-next-line local-rules/type-alias-readonlydeep
|
||||
type KeyChangedActionType = {
|
||||
type: 'calling/MARK_CALL_UNTRUSTED';
|
||||
payload: {
|
||||
safetyNumberChangedAcis: Array<AciString>;
|
||||
};
|
||||
};
|
||||
|
||||
type KeyChangeOkActionType = ReadonlyDeep<{
|
||||
type: 'calling/MARK_CALL_TRUSTED';
|
||||
payload: null;
|
||||
}>;
|
||||
|
||||
type SendGroupCallRaiseHandActionType = ReadonlyDeep<{
|
||||
type: 'calling/RAISE_HAND_GROUP_CALL';
|
||||
payload: SendGroupCallRaiseHandType;
|
||||
|
@ -865,8 +841,6 @@ export type CallingActionType =
|
|||
| HangUpActionType
|
||||
| IncomingDirectCallActionType
|
||||
| IncomingGroupCallActionType
|
||||
| KeyChangedActionType
|
||||
| KeyChangeOkActionType
|
||||
| OutgoingCallActionType
|
||||
| PeekGroupCallFulfilledActionType
|
||||
| RefreshIODevicesActionType
|
||||
|
@ -1267,56 +1241,6 @@ function hangUpActiveCall(
|
|||
};
|
||||
}
|
||||
|
||||
function keyChanged(
|
||||
payload: KeyChangedType
|
||||
): ThunkAction<void, RootStateType, unknown, KeyChangedActionType> {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const { activeCallState } = state.calling;
|
||||
|
||||
const activeCall = getActiveCall(state.calling);
|
||||
if (!activeCall || !activeCallState) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isGroupOrAdhocCallState(activeCall)) {
|
||||
const acisChanged = new Set(activeCallState.safetyNumberChangedAcis);
|
||||
|
||||
// Iterate over each participant to ensure that the service id passed in
|
||||
// matches one of the participants in the group call.
|
||||
activeCall.remoteParticipants.forEach(participant => {
|
||||
if (participant.aci === payload.aci) {
|
||||
acisChanged.add(participant.aci);
|
||||
}
|
||||
});
|
||||
|
||||
const safetyNumberChangedAcis = Array.from(acisChanged);
|
||||
|
||||
if (safetyNumberChangedAcis.length) {
|
||||
dispatch({
|
||||
type: MARK_CALL_UNTRUSTED,
|
||||
payload: {
|
||||
safetyNumberChangedAcis,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function keyChangeOk(
|
||||
payload: KeyChangeOkType
|
||||
): ThunkAction<void, RootStateType, unknown, KeyChangeOkActionType> {
|
||||
return dispatch => {
|
||||
calling.resendGroupCallMediaKeys(payload.conversationId);
|
||||
|
||||
dispatch({
|
||||
type: MARK_CALL_TRUSTED,
|
||||
payload: null,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function sendGroupCallRaiseHand(
|
||||
payload: SendGroupCallRaiseHandType
|
||||
): ThunkAction<void, RootStateType, unknown, SendGroupCallRaiseHandActionType> {
|
||||
|
@ -2059,8 +1983,6 @@ export const actions = {
|
|||
groupCallRaisedHandsChange,
|
||||
groupCallStateChange,
|
||||
hangUpActiveCall,
|
||||
keyChangeOk,
|
||||
keyChanged,
|
||||
onOutgoingVideoCallInConversation,
|
||||
onOutgoingAudioCallInConversation,
|
||||
openSystemPreferencesAction,
|
||||
|
@ -2284,7 +2206,6 @@ export function reducer(
|
|||
localAudioLevel: 0,
|
||||
viewMode: CallViewMode.Paginated,
|
||||
pip: false,
|
||||
safetyNumberChangedAcis: [],
|
||||
settingsDialogOpen: false,
|
||||
showParticipantsList: false,
|
||||
outgoingRing,
|
||||
|
@ -2314,7 +2235,6 @@ export function reducer(
|
|||
localAudioLevel: 0,
|
||||
viewMode: CallViewMode.Paginated,
|
||||
pip: false,
|
||||
safetyNumberChangedAcis: [],
|
||||
settingsDialogOpen: false,
|
||||
showParticipantsList: false,
|
||||
outgoingRing: true,
|
||||
|
@ -2343,7 +2263,6 @@ export function reducer(
|
|||
localAudioLevel: 0,
|
||||
viewMode: CallViewMode.Paginated,
|
||||
pip: false,
|
||||
safetyNumberChangedAcis: [],
|
||||
settingsDialogOpen: false,
|
||||
showParticipantsList: false,
|
||||
outgoingRing: false,
|
||||
|
@ -2505,7 +2424,6 @@ export function reducer(
|
|||
localAudioLevel: 0,
|
||||
viewMode: CallViewMode.Paginated,
|
||||
pip: false,
|
||||
safetyNumberChangedAcis: [],
|
||||
settingsDialogOpen: false,
|
||||
showParticipantsList: false,
|
||||
outgoingRing: true,
|
||||
|
@ -3182,42 +3100,5 @@ export function reducer(
|
|||
};
|
||||
}
|
||||
|
||||
if (action.type === MARK_CALL_UNTRUSTED) {
|
||||
const { activeCallState } = state;
|
||||
if (!activeCallState) {
|
||||
log.warn('Cannot mark call as untrusted when there is no active call');
|
||||
return state;
|
||||
}
|
||||
|
||||
const { safetyNumberChangedAcis } = action.payload;
|
||||
|
||||
return {
|
||||
...state,
|
||||
activeCallState: {
|
||||
...activeCallState,
|
||||
pip: false,
|
||||
safetyNumberChangedAcis,
|
||||
settingsDialogOpen: false,
|
||||
showParticipantsList: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (action.type === MARK_CALL_TRUSTED) {
|
||||
const { activeCallState } = state;
|
||||
if (!activeCallState) {
|
||||
log.warn('Cannot mark call as trusted when there is no active call');
|
||||
return state;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
activeCallState: {
|
||||
...activeCallState,
|
||||
safetyNumberChangedAcis: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ import { missingCaseError } from '../../util/missingCaseError';
|
|||
import { viewSyncJobQueue } from '../../jobs/viewSyncJobQueue';
|
||||
import { ReadStatus } from '../../messages/MessageReadStatus';
|
||||
import { isIncoming, processBodyRanges } from '../selectors/message';
|
||||
import { getActiveCallState } from '../selectors/calling';
|
||||
import { getActiveCall, getActiveCallState } from '../selectors/calling';
|
||||
import { sendDeleteForEveryoneMessage } from '../../util/sendDeleteForEveryoneMessage';
|
||||
import type { ShowToastActionType } from './toast';
|
||||
import { SHOW_TOAST } from './toast';
|
||||
|
@ -2433,7 +2433,15 @@ export function cancelConversationVerification(
|
|||
});
|
||||
|
||||
// Start the blocked conversation queues up again
|
||||
const activeCall = getActiveCall(state);
|
||||
conversationIdsBlocked.forEach(conversationId => {
|
||||
if (
|
||||
activeCall &&
|
||||
activeCall.conversationId === conversationId &&
|
||||
activeCall.callMode === CallMode.Direct
|
||||
) {
|
||||
calling.hangup(conversationId, 'canceled conversation verification');
|
||||
}
|
||||
conversationJobQueue.resolveVerificationWaiter(conversationId);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -9,7 +9,6 @@ import type {
|
|||
GroupIncomingCall,
|
||||
} from '../../components/CallManager';
|
||||
import { CallManager } from '../../components/CallManager';
|
||||
import type { SafetyNumberProps } from '../../components/SafetyNumberChangeDialog';
|
||||
import { isConversationTooBigToRing as getIsConversationTooBigToRing } from '../../conversations/isConversationTooBigToRing';
|
||||
import * as log from '../../logging/log';
|
||||
import { calling as callingService } from '../../services/calling';
|
||||
|
@ -47,16 +46,14 @@ import type { ConversationType } from '../ducks/conversations';
|
|||
import { useToastActions } from '../ducks/toast';
|
||||
import type { StateType } from '../reducer';
|
||||
import { getHasInitialLoadCompleted } from '../selectors/app';
|
||||
import { getPreferredBadgeSelector } from '../selectors/badges';
|
||||
import {
|
||||
getAvailableCameras,
|
||||
getCallLinkSelector,
|
||||
getIncomingCall,
|
||||
} from '../selectors/calling';
|
||||
import { getConversationSelector, getMe } from '../selectors/conversations';
|
||||
import { getIntl, getTheme } from '../selectors/user';
|
||||
import { getIntl } from '../selectors/user';
|
||||
import { SmartCallingDeviceSelection } from './CallingDeviceSelection';
|
||||
import { SmartSafetyNumberViewer } from './SafetyNumberViewer';
|
||||
import { renderEmojiPicker } from './renderEmojiPicker';
|
||||
import { renderReactionPicker } from './renderReactionPicker';
|
||||
|
||||
|
@ -64,10 +61,6 @@ function renderDeviceSelection(): JSX.Element {
|
|||
return <SmartCallingDeviceSelection />;
|
||||
}
|
||||
|
||||
function renderSafetyNumberViewer(props: SafetyNumberProps): JSX.Element {
|
||||
return <SmartSafetyNumberViewer {...props} />;
|
||||
}
|
||||
|
||||
const getGroupCallVideoFrameSource =
|
||||
callingService.getGroupCallVideoFrameSource.bind(callingService);
|
||||
|
||||
|
@ -216,7 +209,6 @@ const mapStateToActiveCallProp = (
|
|||
} satisfies ActiveDirectCallType;
|
||||
case CallMode.Group:
|
||||
case CallMode.Adhoc: {
|
||||
const conversationsWithSafetyNumberChanges: Array<ConversationType> = [];
|
||||
const groupMembers: Array<ConversationType> = [];
|
||||
const remoteParticipants: Array<GroupCallRemoteParticipantType> = [];
|
||||
const peekedParticipants: Array<ConversationType> = [];
|
||||
|
@ -290,22 +282,6 @@ const mapStateToActiveCallProp = (
|
|||
}
|
||||
});
|
||||
|
||||
for (
|
||||
let i = 0;
|
||||
i < activeCallState.safetyNumberChangedAcis.length;
|
||||
i += 1
|
||||
) {
|
||||
const aci = activeCallState.safetyNumberChangedAcis[i];
|
||||
|
||||
const remoteConversation = conversationSelectorByAci(aci);
|
||||
if (!remoteConversation) {
|
||||
log.error('Remote participant has no corresponding conversation');
|
||||
continue;
|
||||
}
|
||||
|
||||
conversationsWithSafetyNumberChanges.push(remoteConversation);
|
||||
}
|
||||
|
||||
for (let i = 0; i < peekInfo.acis.length; i += 1) {
|
||||
const peekedParticipantAci = peekInfo.acis[i];
|
||||
|
||||
|
@ -323,7 +299,6 @@ const mapStateToActiveCallProp = (
|
|||
...baseResult,
|
||||
callMode: call.callMode,
|
||||
connectionState: call.connectionState,
|
||||
conversationsWithSafetyNumberChanges,
|
||||
conversationsByDemuxId,
|
||||
deviceCount: peekInfo.deviceCount,
|
||||
groupMembers,
|
||||
|
@ -422,11 +397,9 @@ const mapStateToIncomingCallProp = (
|
|||
|
||||
export const SmartCallManager = memo(function SmartCallManager() {
|
||||
const i18n = useSelector(getIntl);
|
||||
const theme = useSelector(getTheme);
|
||||
const activeCall = useSelector(mapStateToActiveCallProp);
|
||||
const callLink = useSelector(mapStateToCallLinkProp);
|
||||
const incomingCall = useSelector(mapStateToIncomingCallProp);
|
||||
const getPreferredBadge = useSelector(getPreferredBadgeSelector);
|
||||
const availableCameras = useSelector(getAvailableCameras);
|
||||
const hasInitialLoadCompleted = useSelector(getHasInitialLoadCompleted);
|
||||
const me = useSelector(getMe);
|
||||
|
@ -439,7 +412,6 @@ export const SmartCallManager = memo(function SmartCallManager() {
|
|||
closeNeedPermissionScreen,
|
||||
getPresentingSources,
|
||||
cancelCall,
|
||||
keyChangeOk,
|
||||
startCall,
|
||||
toggleParticipants,
|
||||
acceptCall,
|
||||
|
@ -478,7 +450,6 @@ export const SmartCallManager = memo(function SmartCallManager() {
|
|||
closeNeedPermissionScreen={closeNeedPermissionScreen}
|
||||
declineCall={declineCall}
|
||||
getGroupCallVideoFrameSource={getGroupCallVideoFrameSource}
|
||||
getPreferredBadge={getPreferredBadge}
|
||||
getPresentingSources={getPresentingSources}
|
||||
hangUpActiveCall={hangUpActiveCall}
|
||||
hasInitialLoadCompleted={hasInitialLoadCompleted}
|
||||
|
@ -487,7 +458,6 @@ export const SmartCallManager = memo(function SmartCallManager() {
|
|||
isConversationTooBigToRing={isConversationTooBigToRing}
|
||||
isGroupCallRaiseHandEnabled={isGroupCallRaiseHandEnabled()}
|
||||
isGroupCallReactionsEnabled={isGroupCallReactionsEnabled()}
|
||||
keyChangeOk={keyChangeOk}
|
||||
me={me}
|
||||
notifyForCall={notifyForCall}
|
||||
openSystemPreferencesAction={openSystemPreferencesAction}
|
||||
|
@ -496,7 +466,6 @@ export const SmartCallManager = memo(function SmartCallManager() {
|
|||
renderDeviceSelection={renderDeviceSelection}
|
||||
renderEmojiPicker={renderEmojiPicker}
|
||||
renderReactionPicker={renderReactionPicker}
|
||||
renderSafetyNumberViewer={renderSafetyNumberViewer}
|
||||
sendGroupCallRaiseHand={sendGroupCallRaiseHand}
|
||||
sendGroupCallReaction={sendGroupCallReaction}
|
||||
setGroupCallVideoRequest={setGroupCallVideoRequest}
|
||||
|
@ -512,7 +481,6 @@ export const SmartCallManager = memo(function SmartCallManager() {
|
|||
stopRingtone={stopRingtone}
|
||||
switchFromPresentationView={switchFromPresentationView}
|
||||
switchToPresentationView={switchToPresentationView}
|
||||
theme={theme}
|
||||
toggleParticipants={toggleParticipants}
|
||||
togglePip={togglePip}
|
||||
toggleScreenRecordingPermissionsDialog={
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue