From 92eb0361964313073f3681372a1440ccde0fe851 Mon Sep 17 00:00:00 2001 From: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com> Date: Thu, 11 Apr 2024 13:41:49 -0700 Subject: [PATCH] Allow PiP while awaiting approval to join adhoc calls --- ts/components/CallManager.tsx | 37 +++++++++++++------------ ts/components/CallingLobby.stories.tsx | 1 + ts/components/CallingLobby.tsx | 11 +++++++- ts/components/CallingPipRemoteVideo.tsx | 9 ++++-- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/ts/components/CallManager.tsx b/ts/components/CallManager.tsx index 6692053c7b98..bc219608e2db 100644 --- a/ts/components/CallManager.tsx +++ b/ts/components/CallManager.tsx @@ -311,6 +311,24 @@ function ActiveCallManager({ throw missingCaseError(activeCall); } + if (pip) { + return ( + + ); + } + if (showCallLobby) { return ( <> @@ -336,6 +354,7 @@ function ActiveCallManager({ setOutgoingRing={setOutgoingRing} showParticipantsList={showParticipantsList} toggleParticipants={toggleParticipants} + togglePip={togglePip} toggleSettings={toggleSettings} /> {settingsDialogOpen && renderDeviceSelection()} @@ -361,24 +380,6 @@ function ActiveCallManager({ ); } - if (pip) { - return ( - - ); - } - let isHandRaised = false; if (isGroupOrAdhocActiveCall(activeCall)) { const { raisedHands, localDemuxId } = activeCall; diff --git a/ts/components/CallingLobby.stories.tsx b/ts/components/CallingLobby.stories.tsx index d225e9a61402..72e91af9d54e 100644 --- a/ts/components/CallingLobby.stories.tsx +++ b/ts/components/CallingLobby.stories.tsx @@ -75,6 +75,7 @@ const createProps = (overrideProps: Partial = {}): PropsType => { setOutgoingRing: action('set-outgoing-ring'), showParticipantsList: overrideProps.showParticipantsList ?? false, toggleParticipants: action('toggle-participants'), + togglePip: action('toggle-pip'), toggleSettings: action('toggle-settings'), }; }; diff --git a/ts/components/CallingLobby.tsx b/ts/components/CallingLobby.tsx index dbcafde81d14..fb338e695ff4 100644 --- a/ts/components/CallingLobby.tsx +++ b/ts/components/CallingLobby.tsx @@ -75,6 +75,7 @@ export type PropsType = { setOutgoingRing: (_: boolean) => void; showParticipantsList: boolean; toggleParticipants: () => void; + togglePip: () => void; toggleSettings: () => void; }; @@ -98,6 +99,7 @@ export function CallingLobby({ setLocalVideo, setOutgoingRing, toggleParticipants, + togglePip, toggleSettings, outgoingRing, }: PropsType): JSX.Element { @@ -119,6 +121,10 @@ export function CallingLobby({ setOutgoingRing(!outgoingRing); }, [outgoingRing, setOutgoingRing]); + const togglePipForCallingHeader = isAdhocJoinRequestPending + ? togglePip + : undefined; + React.useEffect(() => { setLocalPreview({ element: localVideoRef }); @@ -155,7 +161,9 @@ export function CallingLobby({ const isOnline = useIsOnline(); - const [isCallConnecting, setIsCallConnecting] = React.useState(false); + const [isCallConnecting, setIsCallConnecting] = React.useState( + isAdhocJoinRequestPending || false + ); // eslint-disable-next-line no-nested-ternary const videoButtonType = hasLocalVideo @@ -266,6 +274,7 @@ export function CallingLobby({ i18n={i18n} isGroupCall={isGroupOrAdhocCall} participantCount={peekedParticipants.length} + togglePip={togglePipForCallingHeader} toggleSettings={toggleSettings} onCancel={onCallCanceled} /> diff --git a/ts/components/CallingPipRemoteVideo.tsx b/ts/components/CallingPipRemoteVideo.tsx index ab373029fe10..f06d29561f3f 100644 --- a/ts/components/CallingPipRemoteVideo.tsx +++ b/ts/components/CallingPipRemoteVideo.tsx @@ -14,7 +14,7 @@ import type { GroupCallRemoteParticipantType, GroupCallVideoRequest, } from '../types/Calling'; -import { CallMode } from '../types/Calling'; +import { CallMode, GroupCallJoinState } from '../types/Calling'; import { AvatarColors } from '../types/Colors'; import type { SetRendererCanvasType } from '../state/ducks/calling'; import { useGetCallingFrameBuffer } from '../calling/useGetCallingFrameBuffer'; @@ -41,6 +41,7 @@ function NoVideo({ acceptedMessageRequest, avatarPath, color, + type: conversationType, isMe, phoneNumber, profileName, @@ -58,7 +59,7 @@ function NoVideo({ badge={undefined} color={color || AvatarColors[0]} noteToSelf={false} - conversationType="direct" + conversationType={conversationType} i18n={i18n} isMe={isMe} phoneNumber={phoneNumber} @@ -103,6 +104,10 @@ export function CallingPipRemoteVideo({ return undefined; } + if (activeCall.joinState !== GroupCallJoinState.Joined) { + return undefined; + } + return maxBy(activeCall.remoteParticipants, participant => participant.presenting ? Infinity : participant.speakerTime || -Infinity );