2021-01-08 18:58:28 +00:00
|
|
|
// Copyright 2020-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-10-01 00:43:05 +00:00
|
|
|
import * as React from 'react';
|
2021-08-17 21:45:18 +00:00
|
|
|
import { times } from 'lodash';
|
2020-10-01 00:43:05 +00:00
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
import { boolean } from '@storybook/addon-knobs';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
import { AvatarColors } from '../types/Colors';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ConversationType } from '../state/ducks/conversations';
|
|
|
|
import type { PropsType } from './CallingPip';
|
|
|
|
import { CallingPip } from './CallingPip';
|
|
|
|
import type { ActiveCallType } from '../types/Calling';
|
2020-11-17 15:07:53 +00:00
|
|
|
import {
|
|
|
|
CallMode,
|
|
|
|
CallState,
|
|
|
|
GroupCallConnectionState,
|
|
|
|
GroupCallJoinState,
|
|
|
|
} from '../types/Calling';
|
2021-05-07 22:21:10 +00:00
|
|
|
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
|
2021-01-08 18:58:28 +00:00
|
|
|
import { fakeGetGroupCallVideoFrameSource } from '../test-both/helpers/fakeGetGroupCallVideoFrameSource';
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../util/setupI18n';
|
2020-10-01 00:43:05 +00:00
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
2021-05-07 22:21:10 +00:00
|
|
|
const conversation: ConversationType = getDefaultConversation({
|
2020-10-08 01:25:33 +00:00
|
|
|
id: '3051234567',
|
2020-10-01 00:43:05 +00:00
|
|
|
avatarPath: undefined,
|
2021-05-28 16:15:17 +00:00
|
|
|
color: AvatarColors[0],
|
2020-10-01 00:43:05 +00:00
|
|
|
title: 'Rick Sanchez',
|
|
|
|
name: 'Rick Sanchez',
|
|
|
|
phoneNumber: '3051234567',
|
|
|
|
profileName: 'Rick Sanchez',
|
2021-05-07 22:21:10 +00:00
|
|
|
});
|
2020-11-17 15:07:53 +00:00
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
const getCommonActiveCallData = () => ({
|
|
|
|
conversation,
|
|
|
|
hasLocalAudio: boolean('hasLocalAudio', true),
|
|
|
|
hasLocalVideo: boolean('hasLocalVideo', false),
|
2021-01-08 22:57:54 +00:00
|
|
|
isInSpeakerView: boolean('isInSpeakerView', false),
|
2020-12-02 18:14:03 +00:00
|
|
|
joinedAt: Date.now(),
|
2021-08-25 21:42:51 +00:00
|
|
|
outgoingRing: true,
|
2020-12-02 18:14:03 +00:00
|
|
|
pip: true,
|
|
|
|
settingsDialogOpen: false,
|
|
|
|
showParticipantsList: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
const defaultCall: ActiveCallType = {
|
|
|
|
...getCommonActiveCallData(),
|
2020-11-17 15:07:53 +00:00
|
|
|
callMode: CallMode.Direct as CallMode.Direct,
|
|
|
|
callState: CallState.Accepted,
|
2020-12-02 18:14:03 +00:00
|
|
|
peekedParticipants: [],
|
2021-05-20 21:54:03 +00:00
|
|
|
remoteParticipants: [
|
|
|
|
{ hasRemoteVideo: true, presenting: false, title: 'Arsene' },
|
|
|
|
],
|
2020-10-01 00:43:05 +00:00
|
|
|
};
|
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
|
|
|
|
activeCall: overrideProps.activeCall || defaultCall,
|
2021-01-08 18:58:28 +00:00
|
|
|
getGroupCallVideoFrameSource: fakeGetGroupCallVideoFrameSource,
|
2020-10-01 00:43:05 +00:00
|
|
|
hangUp: action('hang-up'),
|
|
|
|
hasLocalVideo: boolean('hasLocalVideo', overrideProps.hasLocalVideo || false),
|
|
|
|
i18n,
|
2020-12-02 01:52:01 +00:00
|
|
|
setGroupCallVideoRequest: action('set-group-call-video-request'),
|
2020-10-01 00:43:05 +00:00
|
|
|
setLocalPreview: action('set-local-preview'),
|
|
|
|
setRendererCanvas: action('set-renderer-canvas'),
|
|
|
|
togglePip: action('toggle-pip'),
|
2021-10-07 18:56:27 +00:00
|
|
|
toggleSpeakerView: action('toggleSpeakerView'),
|
2020-10-01 00:43:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const story = storiesOf('Components/CallingPip', module);
|
|
|
|
|
|
|
|
story.add('Default', () => {
|
2020-11-19 18:13:36 +00:00
|
|
|
const props = createProps({});
|
2020-10-01 00:43:05 +00:00
|
|
|
return <CallingPip {...props} />;
|
|
|
|
});
|
2020-10-08 01:25:33 +00:00
|
|
|
|
2021-05-07 22:21:10 +00:00
|
|
|
story.add('Contact (with avatar and no video)', () => {
|
2020-12-02 18:14:03 +00:00
|
|
|
const props = createProps({
|
|
|
|
activeCall: {
|
|
|
|
...defaultCall,
|
2020-11-19 18:13:36 +00:00
|
|
|
conversation: {
|
|
|
|
...conversation,
|
|
|
|
avatarPath: 'https://www.fillmurray.com/64/64',
|
|
|
|
},
|
2021-05-20 21:54:03 +00:00
|
|
|
remoteParticipants: [
|
|
|
|
{ hasRemoteVideo: false, presenting: false, title: 'Julian' },
|
|
|
|
],
|
2020-12-02 18:14:03 +00:00
|
|
|
},
|
|
|
|
});
|
2020-10-08 01:25:33 +00:00
|
|
|
return <CallingPip {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Contact (no color)', () => {
|
2020-12-02 18:14:03 +00:00
|
|
|
const props = createProps({
|
|
|
|
activeCall: {
|
|
|
|
...defaultCall,
|
2020-11-19 18:13:36 +00:00
|
|
|
conversation: {
|
|
|
|
...conversation,
|
|
|
|
color: undefined,
|
|
|
|
},
|
2020-12-02 18:14:03 +00:00
|
|
|
},
|
|
|
|
});
|
2020-10-08 01:25:33 +00:00
|
|
|
return <CallingPip {...props} />;
|
|
|
|
});
|
2020-11-17 15:07:53 +00:00
|
|
|
|
|
|
|
story.add('Group Call', () => {
|
2020-12-02 18:14:03 +00:00
|
|
|
const props = createProps({
|
|
|
|
activeCall: {
|
|
|
|
...getCommonActiveCallData(),
|
|
|
|
callMode: CallMode.Group as CallMode.Group,
|
|
|
|
connectionState: GroupCallConnectionState.Connected,
|
2020-12-08 19:37:04 +00:00
|
|
|
conversationsWithSafetyNumberChanges: [],
|
2021-08-17 21:45:18 +00:00
|
|
|
groupMembers: times(3, () => getDefaultConversation()),
|
2020-12-02 18:14:03 +00:00
|
|
|
joinState: GroupCallJoinState.Joined,
|
|
|
|
maxDevices: 5,
|
|
|
|
deviceCount: 0,
|
|
|
|
peekedParticipants: [],
|
|
|
|
remoteParticipants: [],
|
|
|
|
},
|
|
|
|
});
|
2020-11-17 15:07:53 +00:00
|
|
|
return <CallingPip {...props} />;
|
|
|
|
});
|