2021-08-17 21:45:18 +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-08 01:25:33 +00:00
|
|
|
import * as React from 'react';
|
2021-08-17 21:45:18 +00:00
|
|
|
import { times } from 'lodash';
|
2020-10-08 01:25:33 +00:00
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
import { boolean } from '@storybook/addon-knobs';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
2020-12-02 18:14:03 +00:00
|
|
|
import { v4 as generateUuid } from 'uuid';
|
2020-10-08 01:25:33 +00:00
|
|
|
|
2021-05-28 16:15:17 +00:00
|
|
|
import { AvatarColors } from '../types/Colors';
|
2020-12-08 23:35:21 +00:00
|
|
|
import { ConversationType } from '../state/ducks/conversations';
|
2020-10-08 01:25:33 +00:00
|
|
|
import { CallingLobby, PropsType } from './CallingLobby';
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../util/setupI18n';
|
2020-10-08 01:25:33 +00:00
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
2020-12-18 19:16:44 +00:00
|
|
|
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
|
2020-10-08 01:25:33 +00:00
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
2020-10-14 16:30:50 +00:00
|
|
|
const camera = {
|
|
|
|
deviceId: 'dfbe6effe70b0611ba0fdc2a9ea3f39f6cb110e6687948f7e5f016c111b7329c',
|
|
|
|
groupId: '63ee218d2446869e40adfc958ff98263e51f74382b0143328ee4826f20a76f47',
|
|
|
|
kind: 'videoinput' as MediaDeviceKind,
|
|
|
|
label: 'FaceTime HD Camera (Built-in) (9fba:bced)',
|
|
|
|
toJSON() {
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-08-17 21:45:18 +00:00
|
|
|
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => {
|
|
|
|
const isGroupCall = boolean(
|
|
|
|
'isGroupCall',
|
|
|
|
overrideProps.isGroupCall || false
|
|
|
|
);
|
|
|
|
const conversation = isGroupCall
|
|
|
|
? getDefaultConversation({
|
|
|
|
title: 'Tahoe Trip',
|
|
|
|
type: 'group',
|
|
|
|
})
|
|
|
|
: getDefaultConversation();
|
|
|
|
|
|
|
|
return {
|
|
|
|
availableCameras: overrideProps.availableCameras || [camera],
|
|
|
|
conversation,
|
2021-08-25 21:42:51 +00:00
|
|
|
groupMembers:
|
|
|
|
overrideProps.groupMembers ||
|
|
|
|
(isGroupCall ? times(3, () => getDefaultConversation()) : undefined),
|
2021-08-17 21:45:18 +00:00
|
|
|
hasLocalAudio: boolean(
|
|
|
|
'hasLocalAudio',
|
|
|
|
overrideProps.hasLocalAudio || false
|
|
|
|
),
|
|
|
|
hasLocalVideo: boolean(
|
|
|
|
'hasLocalVideo',
|
|
|
|
overrideProps.hasLocalVideo || false
|
|
|
|
),
|
|
|
|
i18n,
|
|
|
|
isGroupCall,
|
2021-08-25 21:42:51 +00:00
|
|
|
isGroupCallOutboundRingEnabled: true,
|
2021-08-17 21:45:18 +00:00
|
|
|
isCallFull: boolean('isCallFull', overrideProps.isCallFull || false),
|
|
|
|
me: overrideProps.me || {
|
|
|
|
color: AvatarColors[0],
|
2021-08-25 21:42:51 +00:00
|
|
|
id: generateUuid(),
|
2021-08-17 21:45:18 +00:00
|
|
|
uuid: generateUuid(),
|
|
|
|
},
|
|
|
|
onCallCanceled: action('on-call-canceled'),
|
|
|
|
onJoinCall: action('on-join-call'),
|
2021-08-25 21:42:51 +00:00
|
|
|
outgoingRing: boolean('outgoingRing', Boolean(overrideProps.outgoingRing)),
|
2021-08-17 21:45:18 +00:00
|
|
|
peekedParticipants: overrideProps.peekedParticipants || [],
|
|
|
|
setLocalAudio: action('set-local-audio'),
|
|
|
|
setLocalPreview: action('set-local-preview'),
|
|
|
|
setLocalVideo: action('set-local-video'),
|
2021-08-25 21:42:51 +00:00
|
|
|
setOutgoingRing: action('set-outgoing-ring'),
|
2021-08-17 21:45:18 +00:00
|
|
|
showParticipantsList: boolean(
|
|
|
|
'showParticipantsList',
|
|
|
|
Boolean(overrideProps.showParticipantsList)
|
|
|
|
),
|
|
|
|
toggleParticipants: action('toggle-participants'),
|
|
|
|
toggleSettings: action('toggle-settings'),
|
|
|
|
};
|
|
|
|
};
|
2020-10-08 01:25:33 +00:00
|
|
|
|
2020-12-08 23:35:21 +00:00
|
|
|
const fakePeekedParticipant = (conversationProps: Partial<ConversationType>) =>
|
2020-12-08 19:37:04 +00:00
|
|
|
getDefaultConversation({
|
|
|
|
uuid: generateUuid(),
|
2020-12-08 23:35:21 +00:00
|
|
|
...conversationProps,
|
2020-12-08 19:37:04 +00:00
|
|
|
});
|
2020-12-02 18:14:03 +00:00
|
|
|
|
2020-10-08 01:25:33 +00:00
|
|
|
const story = storiesOf('Components/CallingLobby', module);
|
|
|
|
|
|
|
|
story.add('Default', () => {
|
|
|
|
const props = createProps();
|
2020-11-09 18:56:20 +00:00
|
|
|
return <CallingLobby {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('No Camera, no avatar', () => {
|
|
|
|
const props = createProps({
|
|
|
|
availableCameras: [],
|
|
|
|
});
|
|
|
|
return <CallingLobby {...props} />;
|
2020-10-08 01:25:33 +00:00
|
|
|
});
|
|
|
|
|
2020-11-09 18:56:20 +00:00
|
|
|
story.add('No Camera, local avatar', () => {
|
2020-10-14 16:30:50 +00:00
|
|
|
const props = createProps({
|
|
|
|
availableCameras: [],
|
2020-11-09 18:56:20 +00:00
|
|
|
me: {
|
|
|
|
avatarPath: '/fixtures/kitten-4-112-112.jpg',
|
2021-05-28 16:15:17 +00:00
|
|
|
color: AvatarColors[0],
|
2021-08-25 21:42:51 +00:00
|
|
|
id: generateUuid(),
|
2020-12-08 19:37:04 +00:00
|
|
|
uuid: generateUuid(),
|
2020-11-09 18:56:20 +00:00
|
|
|
},
|
2020-10-14 16:30:50 +00:00
|
|
|
});
|
|
|
|
return <CallingLobby {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Local Video', () => {
|
|
|
|
const props = createProps({
|
|
|
|
hasLocalVideo: true,
|
|
|
|
});
|
|
|
|
return <CallingLobby {...props} />;
|
|
|
|
});
|
|
|
|
|
2020-10-08 01:25:33 +00:00
|
|
|
story.add('Local Video', () => {
|
|
|
|
const props = createProps({
|
|
|
|
hasLocalVideo: true,
|
|
|
|
});
|
|
|
|
return <CallingLobby {...props} />;
|
|
|
|
});
|
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
story.add('Group Call - 0 peeked participants', () => {
|
|
|
|
const props = createProps({ isGroupCall: true, peekedParticipants: [] });
|
2020-11-17 15:07:53 +00:00
|
|
|
return <CallingLobby {...props} />;
|
|
|
|
});
|
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
story.add('Group Call - 1 peeked participant', () => {
|
|
|
|
const props = createProps({
|
|
|
|
isGroupCall: true,
|
2020-12-08 23:35:21 +00:00
|
|
|
peekedParticipants: [{ title: 'Sam' }].map(fakePeekedParticipant),
|
|
|
|
});
|
|
|
|
return <CallingLobby {...props} />;
|
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Group Call - 1 peeked participant (self)', () => {
|
|
|
|
const uuid = generateUuid();
|
|
|
|
const props = createProps({
|
|
|
|
isGroupCall: true,
|
2021-08-25 21:42:51 +00:00
|
|
|
me: {
|
|
|
|
id: generateUuid(),
|
|
|
|
uuid,
|
|
|
|
},
|
2020-12-08 23:35:21 +00:00
|
|
|
peekedParticipants: [fakePeekedParticipant({ title: 'Ash', uuid })],
|
2020-12-02 18:14:03 +00:00
|
|
|
});
|
2020-11-17 15:07:53 +00:00
|
|
|
return <CallingLobby {...props} />;
|
|
|
|
});
|
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
story.add('Group Call - 4 peeked participants', () => {
|
2020-11-17 15:07:53 +00:00
|
|
|
const props = createProps({
|
|
|
|
isGroupCall: true,
|
2020-12-08 23:35:21 +00:00
|
|
|
peekedParticipants: ['Sam', 'Cayce', 'April', 'Logan', 'Carl'].map(title =>
|
|
|
|
fakePeekedParticipant({ title })
|
2020-12-02 18:14:03 +00:00
|
|
|
),
|
2020-11-17 15:07:53 +00:00
|
|
|
});
|
2020-10-08 01:25:33 +00:00
|
|
|
return <CallingLobby {...props} />;
|
|
|
|
});
|
2020-11-20 19:39:50 +00:00
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
story.add('Group Call - 4 peeked participants (participants list)', () => {
|
2020-11-20 19:39:50 +00:00
|
|
|
const props = createProps({
|
|
|
|
isGroupCall: true,
|
2020-12-08 23:35:21 +00:00
|
|
|
peekedParticipants: ['Sam', 'Cayce', 'April', 'Logan', 'Carl'].map(title =>
|
|
|
|
fakePeekedParticipant({ title })
|
2020-12-02 18:14:03 +00:00
|
|
|
),
|
2020-11-20 19:39:50 +00:00
|
|
|
showParticipantsList: true,
|
|
|
|
});
|
|
|
|
return <CallingLobby {...props} />;
|
|
|
|
});
|
2020-12-08 22:28:44 +00:00
|
|
|
|
|
|
|
story.add('Group Call - call full', () => {
|
|
|
|
const props = createProps({
|
|
|
|
isGroupCall: true,
|
|
|
|
isCallFull: true,
|
2020-12-09 00:48:02 +00:00
|
|
|
peekedParticipants: ['Sam', 'Cayce'].map(title =>
|
|
|
|
fakePeekedParticipant({ title })
|
|
|
|
),
|
2020-12-08 22:28:44 +00:00
|
|
|
});
|
|
|
|
return <CallingLobby {...props} />;
|
|
|
|
});
|
2021-08-25 21:42:51 +00:00
|
|
|
|
|
|
|
story.add('Group Call - 0 peeked participants, big group', () => {
|
|
|
|
const props = createProps({
|
|
|
|
isGroupCall: true,
|
|
|
|
groupMembers: times(100, () => getDefaultConversation()),
|
|
|
|
});
|
|
|
|
return <CallingLobby {...props} />;
|
|
|
|
});
|