// Copyright 2024 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import classNames from 'classnames'; import type { CallStatus } from '../../../types/CallDisposition'; import { CallDirection, CallType, DirectCallStatus, GroupCallStatus, type CallHistoryGroup, } from '../../../types/CallDisposition'; import type { LocalizerType } from '../../../types/I18N'; import { formatDate, formatTime } from '../../../util/timestamp'; import { PanelSection } from './PanelSection'; import { getDirectCallNotificationText } from '../../../util/callingNotification'; function describeCallHistory( i18n: LocalizerType, type: CallType, direction: CallDirection, status: CallStatus ): string { if (type === CallType.Adhoc) { return i18n('icu:CallHistory__Description--Adhoc'); } if ( (type === CallType.Audio || type === CallType.Video) && (status === DirectCallStatus.Accepted || status === DirectCallStatus.Declined || status === DirectCallStatus.Deleted || status === DirectCallStatus.Missed || status === DirectCallStatus.Pending) ) { return getDirectCallNotificationText(direction, type, status, i18n); } if (status === GroupCallStatus.Missed) { if (direction === CallDirection.Incoming) { return i18n('icu:CallHistory__DescriptionVideoCall--Missed'); } return i18n('icu:CallHistory__DescriptionVideoCall--Unanswered'); } if (status === GroupCallStatus.Declined) { return i18n('icu:CallHistory__DescriptionVideoCall--Declined'); } return i18n('icu:CallHistory__DescriptionVideoCall--Default', { direction }); } export type CallHistoryPanelSectionProps = Readonly<{ callHistoryGroup: CallHistoryGroup; i18n: LocalizerType; }>; export function CallHistoryGroupPanelSection({ callHistoryGroup, i18n, }: CallHistoryPanelSectionProps): JSX.Element { return (
    {callHistoryGroup.children.map(child => { return (
  1. {describeCallHistory( i18n, callHistoryGroup.type, callHistoryGroup.direction, callHistoryGroup.status )} {formatTime(i18n, child.timestamp, Date.now(), false)}
  2. ); })}
); }