Revert to previous method of rendering calling notifications
This commit is contained in:
parent
3beea78aff
commit
7c16b16ee0
5 changed files with 131 additions and 84 deletions
|
@ -21,7 +21,6 @@ import {
|
||||||
DirectCallStatus,
|
DirectCallStatus,
|
||||||
} from '../../types/CallDisposition';
|
} from '../../types/CallDisposition';
|
||||||
import type { ConversationType } from '../../state/ducks/conversations';
|
import type { ConversationType } from '../../state/ducks/conversations';
|
||||||
import { CallExternalState } from '../../util/callingNotification';
|
|
||||||
|
|
||||||
const i18n = setupI18n('en', enMessages);
|
const i18n = setupI18n('en', enMessages);
|
||||||
|
|
||||||
|
@ -35,7 +34,9 @@ const getCommonProps = (options: {
|
||||||
direction?: CallDirection;
|
direction?: CallDirection;
|
||||||
status?: CallStatus;
|
status?: CallStatus;
|
||||||
callCreator?: ConversationType | null;
|
callCreator?: ConversationType | null;
|
||||||
callExternalState?: CallExternalState;
|
groupCallEnded: boolean | null;
|
||||||
|
deviceCount: number;
|
||||||
|
maxDevices: number;
|
||||||
}): PropsType => {
|
}): PropsType => {
|
||||||
const {
|
const {
|
||||||
mode,
|
mode,
|
||||||
|
@ -48,7 +49,9 @@ const getCommonProps = (options: {
|
||||||
serviceId: generateAci(),
|
serviceId: generateAci(),
|
||||||
isMe: direction === CallDirection.Outgoing,
|
isMe: direction === CallDirection.Outgoing,
|
||||||
}),
|
}),
|
||||||
callExternalState = CallExternalState.Active,
|
groupCallEnded,
|
||||||
|
deviceCount,
|
||||||
|
maxDevices,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
const conversation =
|
const conversation =
|
||||||
|
@ -71,15 +74,10 @@ const getCommonProps = (options: {
|
||||||
status,
|
status,
|
||||||
},
|
},
|
||||||
callCreator,
|
callCreator,
|
||||||
callExternalState,
|
activeConversationId: null,
|
||||||
maxDevices: mode === CallMode.Group ? 15 : 0,
|
groupCallEnded,
|
||||||
deviceCount:
|
maxDevices,
|
||||||
// eslint-disable-next-line no-nested-ternary
|
deviceCount,
|
||||||
mode === CallMode.Group
|
|
||||||
? callExternalState === CallExternalState.Full
|
|
||||||
? 15
|
|
||||||
: 13
|
|
||||||
: Infinity,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,6 +101,9 @@ export function AcceptedIncomingAudioCall(): JSX.Element {
|
||||||
type: CallType.Audio,
|
type: CallType.Audio,
|
||||||
direction: CallDirection.Incoming,
|
direction: CallDirection.Incoming,
|
||||||
status: DirectCallStatus.Accepted,
|
status: DirectCallStatus.Accepted,
|
||||||
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -116,7 +117,9 @@ export function AcceptedIncomingVideoCall(): JSX.Element {
|
||||||
type: CallType.Video,
|
type: CallType.Video,
|
||||||
direction: CallDirection.Incoming,
|
direction: CallDirection.Incoming,
|
||||||
status: DirectCallStatus.Accepted,
|
status: DirectCallStatus.Accepted,
|
||||||
callExternalState: CallExternalState.Ended,
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -130,6 +133,9 @@ export function DeclinedIncomingAudioCall(): JSX.Element {
|
||||||
type: CallType.Audio,
|
type: CallType.Audio,
|
||||||
direction: CallDirection.Incoming,
|
direction: CallDirection.Incoming,
|
||||||
status: DirectCallStatus.Declined,
|
status: DirectCallStatus.Declined,
|
||||||
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -143,6 +149,9 @@ export function DeclinedIncomingVideoCall(): JSX.Element {
|
||||||
type: CallType.Video,
|
type: CallType.Video,
|
||||||
direction: CallDirection.Incoming,
|
direction: CallDirection.Incoming,
|
||||||
status: DirectCallStatus.Declined,
|
status: DirectCallStatus.Declined,
|
||||||
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -156,6 +165,9 @@ export function AcceptedOutgoingAudioCall(): JSX.Element {
|
||||||
type: CallType.Audio,
|
type: CallType.Audio,
|
||||||
direction: CallDirection.Outgoing,
|
direction: CallDirection.Outgoing,
|
||||||
status: DirectCallStatus.Accepted,
|
status: DirectCallStatus.Accepted,
|
||||||
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -169,6 +181,9 @@ export function AcceptedOutgoingVideoCall(): JSX.Element {
|
||||||
type: CallType.Video,
|
type: CallType.Video,
|
||||||
direction: CallDirection.Outgoing,
|
direction: CallDirection.Outgoing,
|
||||||
status: DirectCallStatus.Accepted,
|
status: DirectCallStatus.Accepted,
|
||||||
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -182,6 +197,9 @@ export function DeclinedOutgoingAudioCall(): JSX.Element {
|
||||||
type: CallType.Audio,
|
type: CallType.Audio,
|
||||||
direction: CallDirection.Outgoing,
|
direction: CallDirection.Outgoing,
|
||||||
status: DirectCallStatus.Declined,
|
status: DirectCallStatus.Declined,
|
||||||
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -195,6 +213,9 @@ export function DeclinedOutgoingVideoCall(): JSX.Element {
|
||||||
type: CallType.Video,
|
type: CallType.Video,
|
||||||
direction: CallDirection.Outgoing,
|
direction: CallDirection.Outgoing,
|
||||||
status: DirectCallStatus.Declined,
|
status: DirectCallStatus.Declined,
|
||||||
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -209,7 +230,9 @@ export function TwoIncomingDirectCallsBackToBack(): JSX.Element {
|
||||||
type: CallType.Video,
|
type: CallType.Video,
|
||||||
direction: CallDirection.Incoming,
|
direction: CallDirection.Incoming,
|
||||||
status: DirectCallStatus.Declined,
|
status: DirectCallStatus.Declined,
|
||||||
callExternalState: CallExternalState.Ended,
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
isNextItemCallingNotification
|
isNextItemCallingNotification
|
||||||
/>
|
/>
|
||||||
|
@ -219,6 +242,9 @@ export function TwoIncomingDirectCallsBackToBack(): JSX.Element {
|
||||||
type: CallType.Audio,
|
type: CallType.Audio,
|
||||||
direction: CallDirection.Incoming,
|
direction: CallDirection.Incoming,
|
||||||
status: DirectCallStatus.Declined,
|
status: DirectCallStatus.Declined,
|
||||||
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
@ -238,7 +264,9 @@ export function TwoOutgoingDirectCallsBackToBack(): JSX.Element {
|
||||||
type: CallType.Video,
|
type: CallType.Video,
|
||||||
direction: CallDirection.Outgoing,
|
direction: CallDirection.Outgoing,
|
||||||
status: DirectCallStatus.Declined,
|
status: DirectCallStatus.Declined,
|
||||||
callExternalState: CallExternalState.Ended,
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
isNextItemCallingNotification
|
isNextItemCallingNotification
|
||||||
/>
|
/>
|
||||||
|
@ -248,6 +276,9 @@ export function TwoOutgoingDirectCallsBackToBack(): JSX.Element {
|
||||||
type: CallType.Audio,
|
type: CallType.Audio,
|
||||||
direction: CallDirection.Outgoing,
|
direction: CallDirection.Outgoing,
|
||||||
status: DirectCallStatus.Declined,
|
status: DirectCallStatus.Declined,
|
||||||
|
groupCallEnded: null,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
@ -267,6 +298,9 @@ export function GroupCallByUnknown(): JSX.Element {
|
||||||
direction: CallDirection.Incoming,
|
direction: CallDirection.Incoming,
|
||||||
status: GroupCallStatus.Accepted,
|
status: GroupCallStatus.Accepted,
|
||||||
callCreator: null,
|
callCreator: null,
|
||||||
|
groupCallEnded: false,
|
||||||
|
deviceCount: 1,
|
||||||
|
maxDevices: 8,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -280,6 +314,9 @@ export function GroupCallByYou(): JSX.Element {
|
||||||
type: CallType.Group,
|
type: CallType.Group,
|
||||||
direction: CallDirection.Outgoing,
|
direction: CallDirection.Outgoing,
|
||||||
status: GroupCallStatus.Accepted,
|
status: GroupCallStatus.Accepted,
|
||||||
|
groupCallEnded: false,
|
||||||
|
deviceCount: 1,
|
||||||
|
maxDevices: 8,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -293,6 +330,9 @@ export function GroupCallBySomeone(): JSX.Element {
|
||||||
type: CallType.Group,
|
type: CallType.Group,
|
||||||
direction: CallDirection.Incoming,
|
direction: CallDirection.Incoming,
|
||||||
status: GroupCallStatus.GenericGroupCall,
|
status: GroupCallStatus.GenericGroupCall,
|
||||||
|
groupCallEnded: false,
|
||||||
|
deviceCount: 1,
|
||||||
|
maxDevices: 8,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -309,6 +349,9 @@ export function GroupCallStartedBySomeoneWithALongName(): JSX.Element {
|
||||||
callCreator: getDefaultConversation({
|
callCreator: getDefaultConversation({
|
||||||
name: '😤🪐🦆'.repeat(50),
|
name: '😤🪐🦆'.repeat(50),
|
||||||
}),
|
}),
|
||||||
|
groupCallEnded: false,
|
||||||
|
deviceCount: 1,
|
||||||
|
maxDevices: 8,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -326,7 +369,9 @@ export function GroupCallActiveCallFull(): JSX.Element {
|
||||||
type: CallType.Group,
|
type: CallType.Group,
|
||||||
direction: CallDirection.Incoming,
|
direction: CallDirection.Incoming,
|
||||||
status: GroupCallStatus.GenericGroupCall,
|
status: GroupCallStatus.GenericGroupCall,
|
||||||
callExternalState: CallExternalState.Full,
|
groupCallEnded: false,
|
||||||
|
deviceCount: 8,
|
||||||
|
maxDevices: 8,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -344,7 +389,9 @@ export function GroupCallEnded(): JSX.Element {
|
||||||
type: CallType.Group,
|
type: CallType.Group,
|
||||||
direction: CallDirection.Incoming,
|
direction: CallDirection.Incoming,
|
||||||
status: GroupCallStatus.GenericGroupCall,
|
status: GroupCallStatus.GenericGroupCall,
|
||||||
callExternalState: CallExternalState.Ended,
|
groupCallEnded: true,
|
||||||
|
deviceCount: 0,
|
||||||
|
maxDevices: Infinity,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,7 +12,6 @@ import type { LocalizerType } from '../../types/Util';
|
||||||
import { CallMode } from '../../types/Calling';
|
import { CallMode } from '../../types/Calling';
|
||||||
import type { CallingNotificationType } from '../../util/callingNotification';
|
import type { CallingNotificationType } from '../../util/callingNotification';
|
||||||
import {
|
import {
|
||||||
CallExternalState,
|
|
||||||
getCallingIcon,
|
getCallingIcon,
|
||||||
getCallingNotificationText,
|
getCallingNotificationText,
|
||||||
} from '../../util/callingNotification';
|
} from '../../util/callingNotification';
|
||||||
|
@ -110,10 +109,7 @@ function renderCallingNotificationButton(
|
||||||
direction === CallDirection.Incoming
|
direction === CallDirection.Incoming
|
||||||
? i18n('icu:calling__call-back')
|
? i18n('icu:calling__call-back')
|
||||||
: i18n('icu:calling__call-again');
|
: i18n('icu:calling__call-again');
|
||||||
if (
|
if (props.activeConversationId != null) {
|
||||||
props.callExternalState === CallExternalState.Joined ||
|
|
||||||
props.callExternalState === CallExternalState.InOtherCall
|
|
||||||
) {
|
|
||||||
disabledTooltipText = i18n('icu:calling__in-another-call-tooltip');
|
disabledTooltipText = i18n('icu:calling__in-another-call-tooltip');
|
||||||
onClick = noop;
|
onClick = noop;
|
||||||
} else {
|
} else {
|
||||||
|
@ -127,17 +123,19 @@ function renderCallingNotificationButton(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CallMode.Group: {
|
case CallMode.Group: {
|
||||||
if (props.callExternalState === CallExternalState.Ended) {
|
if (props.groupCallEnded) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (props.callExternalState === CallExternalState.Joined) {
|
if (props.activeConversationId != null) {
|
||||||
buttonText = i18n('icu:calling__return');
|
if (props.activeConversationId === conversationId) {
|
||||||
onClick = returnToActiveCall;
|
buttonText = i18n('icu:calling__return');
|
||||||
} else if (props.callExternalState === CallExternalState.InOtherCall) {
|
onClick = returnToActiveCall;
|
||||||
buttonText = i18n('icu:calling__join');
|
} else {
|
||||||
disabledTooltipText = i18n('icu:calling__in-another-call-tooltip');
|
buttonText = i18n('icu:calling__join');
|
||||||
onClick = noop;
|
disabledTooltipText = i18n('icu:calling__in-another-call-tooltip');
|
||||||
} else if (props.callExternalState === CallExternalState.Full) {
|
onClick = noop;
|
||||||
|
}
|
||||||
|
} else if (props.deviceCount > props.maxDevices) {
|
||||||
buttonText = i18n('icu:calling__call-is-full');
|
buttonText = i18n('icu:calling__call-is-full');
|
||||||
disabledTooltipText = i18n(
|
disabledTooltipText = i18n(
|
||||||
'icu:calling__call-notification__button__call-full-tooltip',
|
'icu:calling__call-notification__button__call-full-tooltip',
|
||||||
|
@ -146,13 +144,11 @@ function renderCallingNotificationButton(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
onClick = noop;
|
onClick = noop;
|
||||||
} else if (props.callExternalState === CallExternalState.Active) {
|
} else {
|
||||||
buttonText = i18n('icu:calling__join');
|
buttonText = i18n('icu:calling__join');
|
||||||
onClick = () => {
|
onClick = () => {
|
||||||
startCallingLobby({ conversationId, isVideoCall: true });
|
startCallingLobby({ conversationId, isVideoCall: true });
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
throw missingCaseError(props.callExternalState);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,6 @@ import { isVoiceMessage, canBeDownloaded } from '../../types/Attachment';
|
||||||
import { ReadStatus } from '../../messages/MessageReadStatus';
|
import { ReadStatus } from '../../messages/MessageReadStatus';
|
||||||
|
|
||||||
import type { CallingNotificationType } from '../../util/callingNotification';
|
import type { CallingNotificationType } from '../../util/callingNotification';
|
||||||
import { CallExternalState } from '../../util/callingNotification';
|
|
||||||
import { getRecipients } from '../../util/getRecipients';
|
import { getRecipients } from '../../util/getRecipients';
|
||||||
import { getOwn } from '../../util/getOwn';
|
import { getOwn } from '../../util/getOwn';
|
||||||
import { isNotNil } from '../../util/isNotNil';
|
import { isNotNil } from '../../util/isNotNil';
|
||||||
|
@ -134,6 +133,7 @@ import { getMessageSentTimestamp } from '../../util/getMessageSentTimestamp';
|
||||||
import type { CallHistorySelectorType } from './callHistory';
|
import type { CallHistorySelectorType } from './callHistory';
|
||||||
import { CallMode } from '../../types/Calling';
|
import { CallMode } from '../../types/Calling';
|
||||||
import { CallDirection } from '../../types/CallDisposition';
|
import { CallDirection } from '../../types/CallDisposition';
|
||||||
|
import { getCallIdFromEra } from '../../util/callDisposition';
|
||||||
|
|
||||||
export { isIncoming, isOutgoing, isStory };
|
export { isIncoming, isOutgoing, isStory };
|
||||||
|
|
||||||
|
@ -1317,10 +1317,11 @@ export type GetPropsForCallHistoryOptions = Pick<
|
||||||
| 'ourConversationId'
|
| 'ourConversationId'
|
||||||
>;
|
>;
|
||||||
|
|
||||||
const emptyCallNotification = {
|
const emptyCallNotification: CallingNotificationType = {
|
||||||
callHistory: null,
|
callHistory: null,
|
||||||
callCreator: null,
|
callCreator: null,
|
||||||
callExternalState: CallExternalState.Ended,
|
activeConversationId: null,
|
||||||
|
groupCallEnded: null,
|
||||||
maxDevices: Infinity,
|
maxDevices: Infinity,
|
||||||
deviceCount: 0,
|
deviceCount: 0,
|
||||||
};
|
};
|
||||||
|
@ -1346,6 +1347,8 @@ export function getPropsForCallHistory(
|
||||||
return emptyCallNotification;
|
return emptyCallNotification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const activeConversationId = activeCall?.conversationId ?? null;
|
||||||
|
|
||||||
const conversation = conversationSelector(callHistory.peerId);
|
const conversation = conversationSelector(callHistory.peerId);
|
||||||
strictAssert(
|
strictAssert(
|
||||||
conversation != null,
|
conversation != null,
|
||||||
|
@ -1359,38 +1362,39 @@ export function getPropsForCallHistory(
|
||||||
callCreator = conversationSelector(ourConversationId);
|
callCreator = conversationSelector(ourConversationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const call = callSelector(callHistory.callId);
|
if (callHistory.mode === CallMode.Direct) {
|
||||||
|
return {
|
||||||
let deviceCount = 0;
|
callHistory,
|
||||||
let maxDevices = Infinity;
|
callCreator,
|
||||||
if (
|
activeConversationId,
|
||||||
call?.callMode === CallMode.Group &&
|
groupCallEnded: false,
|
||||||
call.peekInfo?.deviceCount != null &&
|
deviceCount: 0,
|
||||||
call.peekInfo?.maxDevices != null
|
maxDevices: Infinity,
|
||||||
) {
|
};
|
||||||
deviceCount = call.peekInfo.deviceCount;
|
|
||||||
maxDevices = call.peekInfo.maxDevices;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let callExternalState: CallExternalState;
|
// This could be a later call in the conversation
|
||||||
if (call == null || deviceCount === 0) {
|
const conversationCall = callSelector(conversation.id);
|
||||||
callExternalState = CallExternalState.Ended;
|
|
||||||
} else if (activeCall != null) {
|
if (conversationCall != null) {
|
||||||
if (activeCall.conversationId === call.conversationId) {
|
strictAssert(
|
||||||
callExternalState = CallExternalState.Joined;
|
conversationCall?.callMode === CallMode.Group,
|
||||||
} else {
|
'getPropsForCallHistory: Call was expected to be a group call'
|
||||||
callExternalState = CallExternalState.InOtherCall;
|
);
|
||||||
}
|
|
||||||
} else if (deviceCount >= maxDevices) {
|
|
||||||
callExternalState = CallExternalState.Full;
|
|
||||||
} else {
|
|
||||||
callExternalState = CallExternalState.Active;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const conversationCallId =
|
||||||
|
conversationCall?.peekInfo?.eraId != null &&
|
||||||
|
getCallIdFromEra(conversationCall.peekInfo.eraId);
|
||||||
|
|
||||||
|
const deviceCount = conversationCall?.peekInfo?.deviceCount ?? 0;
|
||||||
|
const maxDevices = conversationCall?.peekInfo?.maxDevices ?? Infinity;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
callHistory,
|
callHistory,
|
||||||
callCreator,
|
callCreator,
|
||||||
callExternalState,
|
activeConversationId,
|
||||||
|
groupCallEnded: callId !== conversationCallId || deviceCount === 0,
|
||||||
deviceCount,
|
deviceCount,
|
||||||
maxDevices,
|
maxDevices,
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,10 +2,7 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import { assert } from 'chai';
|
import { assert } from 'chai';
|
||||||
import {
|
import { getCallingNotificationText } from '../../util/callingNotification';
|
||||||
CallExternalState,
|
|
||||||
getCallingNotificationText,
|
|
||||||
} from '../../util/callingNotification';
|
|
||||||
import { CallMode } from '../../types/Calling';
|
import { CallMode } from '../../types/Calling';
|
||||||
import { setupI18n } from '../../util/setupI18n';
|
import { setupI18n } from '../../util/setupI18n';
|
||||||
import enMessages from '../../../_locales/en/messages.json';
|
import enMessages from '../../../_locales/en/messages.json';
|
||||||
|
@ -42,7 +39,8 @@ describe('calling notification helpers', () => {
|
||||||
status: GroupCallStatus.Missed,
|
status: GroupCallStatus.Missed,
|
||||||
},
|
},
|
||||||
callCreator,
|
callCreator,
|
||||||
callExternalState: CallExternalState.Ended,
|
activeConversationId: null,
|
||||||
|
groupCallEnded: true,
|
||||||
deviceCount: 1,
|
deviceCount: 1,
|
||||||
maxDevices: 23,
|
maxDevices: 23,
|
||||||
},
|
},
|
||||||
|
@ -70,7 +68,8 @@ describe('calling notification helpers', () => {
|
||||||
status: GroupCallStatus.Ringing,
|
status: GroupCallStatus.Ringing,
|
||||||
},
|
},
|
||||||
callCreator,
|
callCreator,
|
||||||
callExternalState: CallExternalState.Active,
|
activeConversationId: null,
|
||||||
|
groupCallEnded: false,
|
||||||
deviceCount: 1,
|
deviceCount: 1,
|
||||||
maxDevices: 23,
|
maxDevices: 23,
|
||||||
},
|
},
|
||||||
|
@ -99,7 +98,8 @@ describe('calling notification helpers', () => {
|
||||||
status: GroupCallStatus.Ringing,
|
status: GroupCallStatus.Ringing,
|
||||||
},
|
},
|
||||||
callCreator,
|
callCreator,
|
||||||
callExternalState: CallExternalState.Active,
|
activeConversationId: null,
|
||||||
|
groupCallEnded: false,
|
||||||
deviceCount: 1,
|
deviceCount: 1,
|
||||||
maxDevices: 23,
|
maxDevices: 23,
|
||||||
},
|
},
|
||||||
|
@ -127,7 +127,8 @@ describe('calling notification helpers', () => {
|
||||||
status: GroupCallStatus.Ringing,
|
status: GroupCallStatus.Ringing,
|
||||||
},
|
},
|
||||||
callCreator,
|
callCreator,
|
||||||
callExternalState: CallExternalState.Active,
|
activeConversationId: null,
|
||||||
|
groupCallEnded: false,
|
||||||
deviceCount: 1,
|
deviceCount: 1,
|
||||||
maxDevices: 23,
|
maxDevices: 23,
|
||||||
},
|
},
|
||||||
|
@ -152,7 +153,8 @@ describe('calling notification helpers', () => {
|
||||||
status: GroupCallStatus.Ringing,
|
status: GroupCallStatus.Ringing,
|
||||||
},
|
},
|
||||||
callCreator: null,
|
callCreator: null,
|
||||||
callExternalState: CallExternalState.Active,
|
activeConversationId: null,
|
||||||
|
groupCallEnded: false,
|
||||||
deviceCount: 1,
|
deviceCount: 1,
|
||||||
maxDevices: 23,
|
maxDevices: 23,
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,20 +12,14 @@ import {
|
||||||
CallType,
|
CallType,
|
||||||
} from '../types/CallDisposition';
|
} from '../types/CallDisposition';
|
||||||
import type { ConversationType } from '../state/ducks/conversations';
|
import type { ConversationType } from '../state/ducks/conversations';
|
||||||
|
import { strictAssert } from './assert';
|
||||||
export enum CallExternalState {
|
|
||||||
Active,
|
|
||||||
Full,
|
|
||||||
Joined,
|
|
||||||
Ended,
|
|
||||||
InOtherCall,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CallingNotificationType = Readonly<{
|
export type CallingNotificationType = Readonly<{
|
||||||
// In some older calls, we don't have a call id, this hardens against that.
|
// In some older calls, we don't have a call id, this hardens against that.
|
||||||
callHistory: CallHistoryDetails | null;
|
callHistory: CallHistoryDetails | null;
|
||||||
callCreator: ConversationType | null;
|
callCreator: ConversationType | null;
|
||||||
callExternalState: CallExternalState;
|
activeConversationId: string | null;
|
||||||
|
groupCallEnded: boolean | null;
|
||||||
deviceCount: number;
|
deviceCount: number;
|
||||||
maxDevices: number;
|
maxDevices: number;
|
||||||
}>;
|
}>;
|
||||||
|
@ -90,11 +84,11 @@ function getDirectCallNotificationText(
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGroupCallNotificationText(
|
function getGroupCallNotificationText(
|
||||||
callExternalState: CallExternalState,
|
groupCallEnded: boolean,
|
||||||
creator: ConversationType | null,
|
creator: ConversationType | null,
|
||||||
i18n: LocalizerType
|
i18n: LocalizerType
|
||||||
): string {
|
): string {
|
||||||
if (callExternalState === CallExternalState.Ended) {
|
if (groupCallEnded) {
|
||||||
return i18n('icu:calling__call-notification__ended');
|
return i18n('icu:calling__call-notification__ended');
|
||||||
}
|
}
|
||||||
if (creator == null) {
|
if (creator == null) {
|
||||||
|
@ -112,7 +106,7 @@ export function getCallingNotificationText(
|
||||||
callingNotification: CallingNotificationType,
|
callingNotification: CallingNotificationType,
|
||||||
i18n: LocalizerType
|
i18n: LocalizerType
|
||||||
): string | null {
|
): string | null {
|
||||||
const { callHistory, callCreator, callExternalState } = callingNotification;
|
const { callHistory, callCreator, groupCallEnded } = callingNotification;
|
||||||
if (callHistory == null) {
|
if (callHistory == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +120,11 @@ export function getCallingNotificationText(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (callHistory.mode === CallMode.Group) {
|
if (callHistory.mode === CallMode.Group) {
|
||||||
return getGroupCallNotificationText(callExternalState, callCreator, i18n);
|
strictAssert(
|
||||||
|
groupCallEnded != null,
|
||||||
|
'getCallingNotificationText: groupCallEnded shouldnt be null for a group call'
|
||||||
|
);
|
||||||
|
return getGroupCallNotificationText(groupCallEnded, callCreator, i18n);
|
||||||
}
|
}
|
||||||
throw missingCaseError(callHistory.mode);
|
throw missingCaseError(callHistory.mode);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue