While in call link call show unknown contacts discretely

This commit is contained in:
ayumi-signal 2024-07-08 11:17:51 -07:00 committed by GitHub
parent 82941c6c4a
commit 92f25e8a75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 74 additions and 8 deletions

View file

@ -7,7 +7,6 @@ import type { Meta } from '@storybook/react';
import type { PropsType } from './CallManager'; import type { PropsType } from './CallManager';
import { CallManager } from './CallManager'; import { CallManager } from './CallManager';
import { import {
type ActiveGroupCallType,
CallEndedReason, CallEndedReason,
CallMode, CallMode,
CallState, CallState,
@ -15,6 +14,10 @@ import {
GroupCallConnectionState, GroupCallConnectionState,
GroupCallJoinState, GroupCallJoinState,
} from '../types/Calling'; } from '../types/Calling';
import type {
ActiveGroupCallType,
GroupCallRemoteParticipantType,
} from '../types/Calling';
import type { import type {
ConversationType, ConversationType,
ConversationTypeType, ConversationTypeType,
@ -55,6 +58,20 @@ const getUnknownContact = (): ConversationType => ({
serviceId: generateAci(), serviceId: generateAci(),
}); });
const getUnknownParticipant = (): GroupCallRemoteParticipantType => ({
...getPlaceholderContact(),
serviceId: generateAci(),
aci: generateAci(),
demuxId: Math.round(10000 * Math.random()),
hasRemoteAudio: true,
hasRemoteVideo: true,
isHandRaised: false,
mediaKeysReceived: false,
presenting: false,
sharingScreen: false,
videoAspectRatio: 1,
});
const getCommonActiveCallData = () => ({ const getCommonActiveCallData = () => ({
conversation: getConversation(), conversation: getConversation(),
joinedAt: Date.now(), joinedAt: Date.now(),
@ -420,6 +437,27 @@ export function CallLinkWithJoinRequestsMany(): JSX.Element {
); );
} }
export function CallLinkWithJoinRequestUnknownContact(): JSX.Element {
return (
<CallManager
{...createProps({
activeCall: getActiveCallForCallLink({
connectionState: GroupCallConnectionState.Connected,
joinState: GroupCallJoinState.Joined,
peekedParticipants: [allRemoteParticipants[0]],
pendingParticipants: [
getUnknownContact(),
allRemoteParticipants[1],
allRemoteParticipants[2],
],
showParticipantsList: false,
}),
callLink: FAKE_CALL_LINK_WITH_ADMIN_KEY,
})}
/>
);
}
export function CallLinkWithJoinRequestsSystemContact(): JSX.Element { export function CallLinkWithJoinRequestsSystemContact(): JSX.Element {
return ( return (
<CallManager <CallManager
@ -475,3 +513,22 @@ export function CallLinkWithJoinRequestsParticipantsOpen(): JSX.Element {
/> />
); );
} }
export function CallLinkWithUnknownContacts(): JSX.Element {
return (
<CallManager
{...createProps({
activeCall: getActiveCallForCallLink({
connectionState: GroupCallConnectionState.Connected,
joinState: GroupCallJoinState.Joined,
remoteParticipants: [
allRemoteParticipants[0],
getUnknownParticipant(),
getUnknownParticipant(),
],
}),
callLink: FAKE_CALL_LINK_WITH_ADMIN_KEY,
})}
/>
);
}

View file

@ -396,6 +396,7 @@ function ActiveCallManager({
callLink={callLink} callLink={callLink}
i18n={i18n} i18n={i18n}
isCallLinkAdmin={isCallLinkAdmin} isCallLinkAdmin={isCallLinkAdmin}
isUnknownContactDiscrete={false}
ourServiceId={me.serviceId} ourServiceId={me.serviceId}
participants={peekedParticipants} participants={peekedParticipants}
onClose={toggleParticipants} onClose={toggleParticipants}
@ -495,6 +496,7 @@ function ActiveCallManager({
callLink={callLink} callLink={callLink}
i18n={i18n} i18n={i18n}
isCallLinkAdmin={isCallLinkAdmin} isCallLinkAdmin={isCallLinkAdmin}
isUnknownContactDiscrete
ourServiceId={me.serviceId} ourServiceId={me.serviceId}
participants={groupCallParticipantsForParticipantsList} participants={groupCallParticipantsForParticipantsList}
onClose={toggleParticipants} onClose={toggleParticipants}

View file

@ -62,6 +62,7 @@ const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
callLink: getCallLink(overrideProps.callLink || {}), callLink: getCallLink(overrideProps.callLink || {}),
i18n, i18n,
isCallLinkAdmin: overrideProps.isCallLinkAdmin || false, isCallLinkAdmin: overrideProps.isCallLinkAdmin || false,
isUnknownContactDiscrete: overrideProps.isUnknownContactDiscrete || false,
ourServiceId: generateAci(), ourServiceId: generateAci(),
participants: overrideProps.participants || [], participants: overrideProps.participants || [],
onClose: action('on-close'), onClose: action('on-close'),

View file

@ -36,6 +36,7 @@ export type PropsType = {
readonly callLink: CallLinkType; readonly callLink: CallLinkType;
readonly i18n: LocalizerType; readonly i18n: LocalizerType;
readonly isCallLinkAdmin: boolean; readonly isCallLinkAdmin: boolean;
readonly isUnknownContactDiscrete: boolean;
readonly ourServiceId: ServiceIdString | undefined; readonly ourServiceId: ServiceIdString | undefined;
readonly participants: Array<ParticipantType>; readonly participants: Array<ParticipantType>;
readonly onClose: () => void; readonly onClose: () => void;
@ -145,6 +146,7 @@ function UnknownContacts({
export function CallingAdhocCallInfo({ export function CallingAdhocCallInfo({
i18n, i18n,
isCallLinkAdmin, isCallLinkAdmin,
isUnknownContactDiscrete,
ourServiceId, ourServiceId,
participants, participants,
blockClient, blockClient,
@ -170,18 +172,20 @@ export function CallingAdhocCallInfo({
onShareCallLinkViaSignal(); onShareCallLinkViaSignal();
}, [onClose, onShareCallLinkViaSignal]); }, [onClose, onShareCallLinkViaSignal]);
const [knownParticipants, unknownParticipants] = React.useMemo< const [visibleParticipants, unknownParticipants] = React.useMemo<
[Array<ParticipantType>, Array<ParticipantType>] [Array<ParticipantType>, Array<ParticipantType>]
>( >(
() => () =>
partition(participants, (participant: ParticipantType) => partition(
Boolean(participant.titleNoDefault) participants,
(participant: ParticipantType) =>
isUnknownContactDiscrete || Boolean(participant.titleNoDefault)
), ),
[participants] [isUnknownContactDiscrete, participants]
); );
const sortedParticipants = React.useMemo<Array<ParticipantType>>( const sortedParticipants = React.useMemo<Array<ParticipantType>>(
() => sortByTitle(knownParticipants), () => sortByTitle(visibleParticipants),
[knownParticipants] [visibleParticipants]
); );
const renderParticipant = React.useCallback( const renderParticipant = React.useCallback(
@ -377,7 +381,9 @@ export function CallingAdhocCallInfo({
{unknownParticipants.length > 0 && ( {unknownParticipants.length > 0 && (
<UnknownContacts <UnknownContacts
i18n={i18n} i18n={i18n}
isInAdditionToKnownContacts={Boolean(knownParticipants.length)} isInAdditionToKnownContacts={Boolean(
visibleParticipants.length
)}
participants={unknownParticipants} participants={unknownParticipants}
showUnknownContactDialog={() => showUnknownContactDialog={() =>
setIsUnknownContactDialogVisible(true) setIsUnknownContactDialogVisible(true)