Update call strings
This commit is contained in:
parent
a634792be7
commit
26140ee3d6
7 changed files with 289 additions and 53 deletions
|
@ -10,9 +10,12 @@ import {
|
|||
DirectCallStatus,
|
||||
type CallHistoryDetails,
|
||||
CallType,
|
||||
GroupCallStatus,
|
||||
} from '../types/CallDisposition';
|
||||
import type { ConversationType } from '../state/ducks/conversations';
|
||||
import { strictAssert } from './assert';
|
||||
import { isMoreRecentThan } from './timestamp';
|
||||
import { MINUTE } from './durations';
|
||||
|
||||
export type CallingNotificationType = Readonly<{
|
||||
// In some older calls, we don't have a call id, this hardens against that.
|
||||
|
@ -26,7 +29,7 @@ export type CallingNotificationType = Readonly<{
|
|||
isTargeted: boolean;
|
||||
}>;
|
||||
|
||||
function getDirectCallNotificationText(
|
||||
export function getDirectCallNotificationText(
|
||||
callDirection: CallDirection,
|
||||
callType: CallType,
|
||||
callStatus: DirectCallStatus,
|
||||
|
@ -85,14 +88,41 @@ function getDirectCallNotificationText(
|
|||
throw missingCaseError(callStatus);
|
||||
}
|
||||
|
||||
function getGroupCallNotificationText(
|
||||
groupCallEnded: boolean,
|
||||
creator: ConversationType | null,
|
||||
i18n: LocalizerType
|
||||
): string {
|
||||
function getGroupCallNotificationText({
|
||||
groupCallEnded,
|
||||
creator,
|
||||
callHistory,
|
||||
i18n,
|
||||
}: {
|
||||
groupCallEnded: boolean;
|
||||
creator: ConversationType | null;
|
||||
callHistory: CallHistoryDetails;
|
||||
i18n: LocalizerType;
|
||||
}): string {
|
||||
if (groupCallEnded) {
|
||||
return i18n('icu:calling__call-notification__ended');
|
||||
const { direction, status, timestamp } = callHistory;
|
||||
if (direction === CallDirection.Incoming) {
|
||||
if (status === GroupCallStatus.Declined) {
|
||||
return i18n('icu:CallHistory__DescriptionVideoCall--Declined');
|
||||
}
|
||||
if (status === GroupCallStatus.Missed) {
|
||||
return i18n('icu:CallHistory__DescriptionVideoCall--Missed');
|
||||
}
|
||||
if (isMoreRecentThan(timestamp, 5 * MINUTE)) {
|
||||
return i18n('icu:calling__call-notification__ended');
|
||||
}
|
||||
return i18n('icu:acceptedIncomingVideoCall');
|
||||
}
|
||||
|
||||
// Outgoing ended group calls
|
||||
if (isMoreRecentThan(timestamp, 5 * MINUTE)) {
|
||||
return i18n('icu:calling__call-notification__ended');
|
||||
}
|
||||
return i18n('icu:acceptedOutgoingVideoCall');
|
||||
}
|
||||
|
||||
// TODO: Active call with participants DESKTOP-7439
|
||||
|
||||
if (creator == null) {
|
||||
return i18n('icu:calling__call-notification__started-by-someone');
|
||||
}
|
||||
|
@ -108,7 +138,11 @@ export function getCallingNotificationText(
|
|||
callingNotification: CallingNotificationType,
|
||||
i18n: LocalizerType
|
||||
): string | null {
|
||||
const { callHistory, callCreator, groupCallEnded } = callingNotification;
|
||||
const {
|
||||
callHistory,
|
||||
callCreator: creator,
|
||||
groupCallEnded,
|
||||
} = callingNotification;
|
||||
if (callHistory == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -126,7 +160,12 @@ export function getCallingNotificationText(
|
|||
groupCallEnded != null,
|
||||
'getCallingNotificationText: groupCallEnded shouldnt be null for a group call'
|
||||
);
|
||||
return getGroupCallNotificationText(groupCallEnded, callCreator, i18n);
|
||||
return getGroupCallNotificationText({
|
||||
groupCallEnded,
|
||||
creator,
|
||||
callHistory,
|
||||
i18n,
|
||||
});
|
||||
}
|
||||
if (callHistory.mode === CallMode.Adhoc) {
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue