2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-07-23 21:34:48 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import * as React from 'react';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
2023-10-11 19:06:43 +00:00
|
|
|
import type { Meta } from '@storybook/react';
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../../util/setupI18n';
|
2021-07-23 21:34:48 +00:00
|
|
|
import enMessages from '../../../_locales/en/messages.json';
|
|
|
|
import { CallMode } from '../../types/Calling';
|
2023-08-10 16:43:33 +00:00
|
|
|
import { generateAci } from '../../types/ServiceId';
|
2023-08-09 00:53:06 +00:00
|
|
|
import { CallingNotification, type PropsType } from './CallingNotification';
|
|
|
|
import {
|
|
|
|
getDefaultConversation,
|
|
|
|
getDefaultGroup,
|
|
|
|
} from '../../test-both/helpers/getDefaultConversation';
|
|
|
|
import type { CallStatus } from '../../types/CallDisposition';
|
|
|
|
import {
|
|
|
|
CallType,
|
|
|
|
CallDirection,
|
|
|
|
GroupCallStatus,
|
|
|
|
DirectCallStatus,
|
|
|
|
} from '../../types/CallDisposition';
|
|
|
|
import type { ConversationType } from '../../state/ducks/conversations';
|
2021-07-23 21:34:48 +00:00
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export default {
|
|
|
|
title: 'Components/Conversation/CallingNotification',
|
2023-10-11 19:06:43 +00:00
|
|
|
} satisfies Meta<PropsType>;
|
2021-07-23 21:34:48 +00:00
|
|
|
|
2023-08-09 00:53:06 +00:00
|
|
|
const getCommonProps = (options: {
|
|
|
|
mode: CallMode;
|
|
|
|
type?: CallType;
|
|
|
|
direction?: CallDirection;
|
|
|
|
status?: CallStatus;
|
|
|
|
callCreator?: ConversationType | null;
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: boolean | null;
|
|
|
|
deviceCount: number;
|
|
|
|
maxDevices: number;
|
2023-08-09 00:53:06 +00:00
|
|
|
}): PropsType => {
|
|
|
|
const {
|
|
|
|
mode,
|
|
|
|
type = mode === CallMode.Group ? CallType.Group : CallType.Audio,
|
|
|
|
direction = CallDirection.Outgoing,
|
|
|
|
status = mode === CallMode.Group
|
|
|
|
? GroupCallStatus.GenericGroupCall
|
|
|
|
: DirectCallStatus.Pending,
|
|
|
|
callCreator = getDefaultConversation({
|
2023-08-16 20:54:39 +00:00
|
|
|
serviceId: generateAci(),
|
2023-08-09 00:53:06 +00:00
|
|
|
isMe: direction === CallDirection.Outgoing,
|
|
|
|
}),
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded,
|
|
|
|
deviceCount,
|
|
|
|
maxDevices,
|
2023-08-09 00:53:06 +00:00
|
|
|
} = options;
|
|
|
|
|
|
|
|
const conversation =
|
|
|
|
mode === CallMode.Group ? getDefaultGroup() : getDefaultConversation();
|
|
|
|
|
|
|
|
return {
|
2023-12-12 16:11:39 +00:00
|
|
|
id: 'message-id',
|
2023-08-09 00:53:06 +00:00
|
|
|
conversationId: conversation.id,
|
|
|
|
i18n,
|
|
|
|
isNextItemCallingNotification: false,
|
2023-09-06 00:34:51 +00:00
|
|
|
onOutgoingAudioCallInConversation: action(
|
|
|
|
'onOutgoingAudioCallInConversation'
|
|
|
|
),
|
|
|
|
onOutgoingVideoCallInConversation: action(
|
|
|
|
'onOutgoingVideoCallInConversation'
|
|
|
|
),
|
2023-12-12 16:11:39 +00:00
|
|
|
toggleDeleteMessagesModal: action('toggleDeleteMessagesModal'),
|
2023-08-09 00:53:06 +00:00
|
|
|
returnToActiveCall: action('returnToActiveCall'),
|
|
|
|
callHistory: {
|
|
|
|
callId: '123',
|
|
|
|
peerId: conversation.id,
|
2023-08-16 20:54:39 +00:00
|
|
|
ringerId: callCreator?.serviceId ?? null,
|
2023-08-09 00:53:06 +00:00
|
|
|
mode,
|
|
|
|
type,
|
|
|
|
direction,
|
|
|
|
timestamp: Date.now(),
|
|
|
|
status,
|
|
|
|
},
|
|
|
|
callCreator,
|
2023-08-21 17:09:54 +00:00
|
|
|
activeConversationId: null,
|
|
|
|
groupCallEnded,
|
|
|
|
maxDevices,
|
|
|
|
deviceCount,
|
2023-12-12 16:11:39 +00:00
|
|
|
isSelectMode: false,
|
|
|
|
isTargeted: false,
|
2023-08-09 00:53:06 +00:00
|
|
|
};
|
|
|
|
};
|
2021-07-23 21:34:48 +00:00
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
/*
|
|
|
|
<CallingNotification
|
|
|
|
{...getCommonProps()}
|
|
|
|
acceptedTime={wasDeclined ? undefined : 1618894800000}
|
|
|
|
callMode={CallMode.Direct}
|
|
|
|
endedTime={1618894800000}
|
|
|
|
wasDeclined={wasDeclined}
|
|
|
|
wasIncoming={wasIncoming}
|
|
|
|
wasVideoCall={wasVideoCall}
|
|
|
|
/>
|
|
|
|
*/
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function AcceptedIncomingAudioCall(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Audio,
|
|
|
|
direction: CallDirection.Incoming,
|
|
|
|
status: DirectCallStatus.Accepted,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2021-07-23 21:34:48 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function AcceptedIncomingVideoCall(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Video,
|
|
|
|
direction: CallDirection.Incoming,
|
|
|
|
status: DirectCallStatus.Accepted,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function DeclinedIncomingAudioCall(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Audio,
|
|
|
|
direction: CallDirection.Incoming,
|
|
|
|
status: DirectCallStatus.Declined,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function DeclinedIncomingVideoCall(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Video,
|
|
|
|
direction: CallDirection.Incoming,
|
|
|
|
status: DirectCallStatus.Declined,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function AcceptedOutgoingAudioCall(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Audio,
|
|
|
|
direction: CallDirection.Outgoing,
|
|
|
|
status: DirectCallStatus.Accepted,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function AcceptedOutgoingVideoCall(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Video,
|
|
|
|
direction: CallDirection.Outgoing,
|
|
|
|
status: DirectCallStatus.Accepted,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function DeclinedOutgoingAudioCall(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Audio,
|
|
|
|
direction: CallDirection.Outgoing,
|
|
|
|
status: DirectCallStatus.Declined,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function DeclinedOutgoingVideoCall(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Video,
|
|
|
|
direction: CallDirection.Outgoing,
|
|
|
|
status: DirectCallStatus.Declined,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function TwoIncomingDirectCallsBackToBack(): JSX.Element {
|
2021-09-10 23:59:41 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Video,
|
|
|
|
direction: CallDirection.Incoming,
|
|
|
|
status: DirectCallStatus.Declined,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-03-28 22:55:12 +00:00
|
|
|
isNextItemCallingNotification
|
2021-09-10 23:59:41 +00:00
|
|
|
/>
|
2023-08-09 00:53:06 +00:00
|
|
|
<CallingNotification
|
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Audio,
|
|
|
|
direction: CallDirection.Incoming,
|
|
|
|
status: DirectCallStatus.Declined,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
|
|
|
/>
|
2021-09-10 23:59:41 +00:00
|
|
|
</>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function TwoOutgoingDirectCallsBackToBack(): JSX.Element {
|
2021-09-10 23:59:41 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Video,
|
|
|
|
direction: CallDirection.Outgoing,
|
|
|
|
status: DirectCallStatus.Declined,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-03-28 22:55:12 +00:00
|
|
|
isNextItemCallingNotification
|
2021-09-10 23:59:41 +00:00
|
|
|
/>
|
2023-08-09 00:53:06 +00:00
|
|
|
<CallingNotification
|
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Direct,
|
|
|
|
type: CallType.Audio,
|
|
|
|
direction: CallDirection.Outgoing,
|
|
|
|
status: DirectCallStatus.Declined,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: null,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
|
|
|
/>
|
2021-09-10 23:59:41 +00:00
|
|
|
</>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2021-09-10 23:59:41 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function GroupCallByUnknown(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Group,
|
|
|
|
type: CallType.Group,
|
|
|
|
direction: CallDirection.Incoming,
|
|
|
|
status: GroupCallStatus.Accepted,
|
|
|
|
callCreator: null,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: false,
|
|
|
|
deviceCount: 1,
|
|
|
|
maxDevices: 8,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function GroupCallByYou(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Group,
|
|
|
|
type: CallType.Group,
|
|
|
|
direction: CallDirection.Outgoing,
|
|
|
|
status: GroupCallStatus.Accepted,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: false,
|
|
|
|
deviceCount: 1,
|
|
|
|
maxDevices: 8,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function GroupCallBySomeone(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Group,
|
|
|
|
type: CallType.Group,
|
|
|
|
direction: CallDirection.Incoming,
|
|
|
|
status: GroupCallStatus.GenericGroupCall,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: false,
|
|
|
|
deviceCount: 1,
|
|
|
|
maxDevices: 8,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2021-07-23 21:34:48 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function GroupCallStartedBySomeoneWithALongName(): JSX.Element {
|
2021-09-02 21:23:27 +00:00
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Group,
|
|
|
|
type: CallType.Group,
|
|
|
|
direction: CallDirection.Incoming,
|
|
|
|
status: GroupCallStatus.GenericGroupCall,
|
|
|
|
callCreator: getDefaultConversation({
|
|
|
|
name: '😤🪐🦆'.repeat(50),
|
|
|
|
}),
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: false,
|
|
|
|
deviceCount: 1,
|
|
|
|
maxDevices: 8,
|
2023-01-12 23:29:07 +00:00
|
|
|
})}
|
2021-09-02 21:23:27 +00:00
|
|
|
/>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function GroupCallActiveCallFull(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Group,
|
|
|
|
type: CallType.Group,
|
|
|
|
direction: CallDirection.Incoming,
|
|
|
|
status: GroupCallStatus.GenericGroupCall,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: false,
|
|
|
|
deviceCount: 8,
|
|
|
|
maxDevices: 8,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2021-07-23 21:34:48 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function GroupCallEnded(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallingNotification
|
2023-08-09 00:53:06 +00:00
|
|
|
{...getCommonProps({
|
|
|
|
mode: CallMode.Group,
|
|
|
|
type: CallType.Group,
|
|
|
|
direction: CallDirection.Incoming,
|
|
|
|
status: GroupCallStatus.GenericGroupCall,
|
2023-08-21 17:09:54 +00:00
|
|
|
groupCallEnded: true,
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-09 00:53:06 +00:00
|
|
|
})}
|
2022-11-18 00:45:19 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|