2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-01-08 18:58:28 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import React from 'react';
|
2021-01-08 18:58:28 +00:00
|
|
|
import { memoize, times } from 'lodash';
|
|
|
|
import { number } from '@storybook/addon-knobs';
|
2021-12-06 23:06:13 +00:00
|
|
|
import { action } from '@storybook/addon-actions';
|
2021-01-08 18:58:28 +00:00
|
|
|
|
|
|
|
import { GroupCallOverflowArea } from './GroupCallOverflowArea';
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../util/setupI18n';
|
2021-10-26 22:59:08 +00:00
|
|
|
import { getDefaultConversationWithUuid } from '../test-both/helpers/getDefaultConversation';
|
2021-01-08 18:58:28 +00:00
|
|
|
import { fakeGetGroupCallVideoFrameSource } from '../test-both/helpers/fakeGetGroupCallVideoFrameSource';
|
|
|
|
import { FRAME_BUFFER_SIZE } from '../calling/constants';
|
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
|
|
|
|
|
|
|
const MAX_PARTICIPANTS = 32;
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const allRemoteParticipants = times(MAX_PARTICIPANTS).map(index => ({
|
|
|
|
demuxId: index,
|
|
|
|
hasRemoteAudio: index % 3 !== 0,
|
|
|
|
hasRemoteVideo: index % 4 !== 0,
|
2021-05-20 21:54:03 +00:00
|
|
|
presenting: false,
|
|
|
|
sharingScreen: false,
|
2021-01-08 18:58:28 +00:00
|
|
|
videoAspectRatio: 1.3,
|
2021-10-26 22:59:08 +00:00
|
|
|
...getDefaultConversationWithUuid({
|
2021-01-08 18:58:28 +00:00
|
|
|
isBlocked: index === 10 || index === MAX_PARTICIPANTS - 1,
|
|
|
|
title: `Participant ${index + 1}`,
|
|
|
|
}),
|
|
|
|
}));
|
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export default {
|
|
|
|
title: 'Components/GroupCallOverflowArea',
|
|
|
|
};
|
2021-01-08 18:58:28 +00:00
|
|
|
|
|
|
|
const defaultProps = {
|
2021-12-11 00:21:28 +00:00
|
|
|
getFrameBuffer: memoize(() => Buffer.alloc(FRAME_BUFFER_SIZE)),
|
2021-01-08 18:58:28 +00:00
|
|
|
getGroupCallVideoFrameSource: fakeGetGroupCallVideoFrameSource,
|
|
|
|
i18n,
|
2021-12-06 23:06:13 +00:00
|
|
|
onParticipantVisibilityChanged: action('onParticipantVisibilityChanged'),
|
2022-05-19 03:28:51 +00:00
|
|
|
remoteAudioLevels: new Map<number, number>(),
|
2023-03-22 17:53:13 +00:00
|
|
|
remoteParticipantsCount: 1,
|
2021-01-08 18:58:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// This component is usually rendered on a call screen.
|
2022-11-18 00:45:19 +00:00
|
|
|
function Container({ children }: { children: JSX.Element }): JSX.Element {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
background: 'black',
|
|
|
|
display: 'inline-flex',
|
|
|
|
height: '80vh',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function NoOverflowedParticipants(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<Container>
|
|
|
|
<GroupCallOverflowArea {...defaultProps} overflowedParticipants={[]} />
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
|
|
|
NoOverflowedParticipants.story = {
|
|
|
|
name: 'No overflowed participants',
|
|
|
|
};
|
2021-01-08 18:58:28 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function OneOverflowedParticipant(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<Container>
|
|
|
|
<GroupCallOverflowArea
|
|
|
|
{...defaultProps}
|
|
|
|
overflowedParticipants={allRemoteParticipants.slice(0, 1)}
|
|
|
|
/>
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
|
|
|
OneOverflowedParticipant.story = {
|
|
|
|
name: 'One overflowed participant',
|
|
|
|
};
|
2021-01-08 18:58:28 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function ThreeOverflowedParticipants(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<Container>
|
|
|
|
<GroupCallOverflowArea
|
|
|
|
{...defaultProps}
|
|
|
|
overflowedParticipants={allRemoteParticipants.slice(0, 3)}
|
|
|
|
/>
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
|
|
|
ThreeOverflowedParticipants.story = {
|
|
|
|
name: 'Three overflowed participants',
|
|
|
|
};
|
2021-01-08 18:58:28 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function ManyOverflowedParticipants(): JSX.Element {
|
|
|
|
return (
|
|
|
|
<Container>
|
|
|
|
<GroupCallOverflowArea
|
|
|
|
{...defaultProps}
|
|
|
|
overflowedParticipants={allRemoteParticipants.slice(
|
|
|
|
0,
|
|
|
|
number('Participant count', MAX_PARTICIPANTS, {
|
|
|
|
range: true,
|
|
|
|
min: 0,
|
|
|
|
max: MAX_PARTICIPANTS,
|
|
|
|
step: 1,
|
|
|
|
})
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
|
|
|
ManyOverflowedParticipants.story = {
|
|
|
|
name: 'Many overflowed participants',
|
|
|
|
};
|