Allow PiP while awaiting approval to join adhoc calls

This commit is contained in:
ayumi-signal 2024-04-11 13:41:49 -07:00 committed by GitHub
parent e21cb6e34a
commit 92eb036196
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 37 additions and 21 deletions

View file

@ -311,6 +311,24 @@ function ActiveCallManager({
throw missingCaseError(activeCall); throw missingCaseError(activeCall);
} }
if (pip) {
return (
<CallingPip
activeCall={activeCall}
getGroupCallVideoFrameSource={getGroupCallVideoFrameSourceForActiveCall}
hangUpActiveCall={hangUpActiveCall}
hasLocalVideo={hasLocalVideo}
i18n={i18n}
setGroupCallVideoRequest={setGroupCallVideoRequestForConversation}
setLocalPreview={setLocalPreview}
setRendererCanvas={setRendererCanvas}
switchToPresentationView={switchToPresentationView}
switchFromPresentationView={switchFromPresentationView}
togglePip={togglePip}
/>
);
}
if (showCallLobby) { if (showCallLobby) {
return ( return (
<> <>
@ -336,6 +354,7 @@ function ActiveCallManager({
setOutgoingRing={setOutgoingRing} setOutgoingRing={setOutgoingRing}
showParticipantsList={showParticipantsList} showParticipantsList={showParticipantsList}
toggleParticipants={toggleParticipants} toggleParticipants={toggleParticipants}
togglePip={togglePip}
toggleSettings={toggleSettings} toggleSettings={toggleSettings}
/> />
{settingsDialogOpen && renderDeviceSelection()} {settingsDialogOpen && renderDeviceSelection()}
@ -361,24 +380,6 @@ function ActiveCallManager({
); );
} }
if (pip) {
return (
<CallingPip
activeCall={activeCall}
getGroupCallVideoFrameSource={getGroupCallVideoFrameSourceForActiveCall}
hangUpActiveCall={hangUpActiveCall}
hasLocalVideo={hasLocalVideo}
i18n={i18n}
setGroupCallVideoRequest={setGroupCallVideoRequestForConversation}
setLocalPreview={setLocalPreview}
setRendererCanvas={setRendererCanvas}
switchToPresentationView={switchToPresentationView}
switchFromPresentationView={switchFromPresentationView}
togglePip={togglePip}
/>
);
}
let isHandRaised = false; let isHandRaised = false;
if (isGroupOrAdhocActiveCall(activeCall)) { if (isGroupOrAdhocActiveCall(activeCall)) {
const { raisedHands, localDemuxId } = activeCall; const { raisedHands, localDemuxId } = activeCall;

View file

@ -75,6 +75,7 @@ const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => {
setOutgoingRing: action('set-outgoing-ring'), setOutgoingRing: action('set-outgoing-ring'),
showParticipantsList: overrideProps.showParticipantsList ?? false, showParticipantsList: overrideProps.showParticipantsList ?? false,
toggleParticipants: action('toggle-participants'), toggleParticipants: action('toggle-participants'),
togglePip: action('toggle-pip'),
toggleSettings: action('toggle-settings'), toggleSettings: action('toggle-settings'),
}; };
}; };

View file

@ -75,6 +75,7 @@ export type PropsType = {
setOutgoingRing: (_: boolean) => void; setOutgoingRing: (_: boolean) => void;
showParticipantsList: boolean; showParticipantsList: boolean;
toggleParticipants: () => void; toggleParticipants: () => void;
togglePip: () => void;
toggleSettings: () => void; toggleSettings: () => void;
}; };
@ -98,6 +99,7 @@ export function CallingLobby({
setLocalVideo, setLocalVideo,
setOutgoingRing, setOutgoingRing,
toggleParticipants, toggleParticipants,
togglePip,
toggleSettings, toggleSettings,
outgoingRing, outgoingRing,
}: PropsType): JSX.Element { }: PropsType): JSX.Element {
@ -119,6 +121,10 @@ export function CallingLobby({
setOutgoingRing(!outgoingRing); setOutgoingRing(!outgoingRing);
}, [outgoingRing, setOutgoingRing]); }, [outgoingRing, setOutgoingRing]);
const togglePipForCallingHeader = isAdhocJoinRequestPending
? togglePip
: undefined;
React.useEffect(() => { React.useEffect(() => {
setLocalPreview({ element: localVideoRef }); setLocalPreview({ element: localVideoRef });
@ -155,7 +161,9 @@ export function CallingLobby({
const isOnline = useIsOnline(); const isOnline = useIsOnline();
const [isCallConnecting, setIsCallConnecting] = React.useState(false); const [isCallConnecting, setIsCallConnecting] = React.useState(
isAdhocJoinRequestPending || false
);
// eslint-disable-next-line no-nested-ternary // eslint-disable-next-line no-nested-ternary
const videoButtonType = hasLocalVideo const videoButtonType = hasLocalVideo
@ -266,6 +274,7 @@ export function CallingLobby({
i18n={i18n} i18n={i18n}
isGroupCall={isGroupOrAdhocCall} isGroupCall={isGroupOrAdhocCall}
participantCount={peekedParticipants.length} participantCount={peekedParticipants.length}
togglePip={togglePipForCallingHeader}
toggleSettings={toggleSettings} toggleSettings={toggleSettings}
onCancel={onCallCanceled} onCancel={onCallCanceled}
/> />

View file

@ -14,7 +14,7 @@ import type {
GroupCallRemoteParticipantType, GroupCallRemoteParticipantType,
GroupCallVideoRequest, GroupCallVideoRequest,
} from '../types/Calling'; } from '../types/Calling';
import { CallMode } from '../types/Calling'; import { CallMode, GroupCallJoinState } from '../types/Calling';
import { AvatarColors } from '../types/Colors'; import { AvatarColors } from '../types/Colors';
import type { SetRendererCanvasType } from '../state/ducks/calling'; import type { SetRendererCanvasType } from '../state/ducks/calling';
import { useGetCallingFrameBuffer } from '../calling/useGetCallingFrameBuffer'; import { useGetCallingFrameBuffer } from '../calling/useGetCallingFrameBuffer';
@ -41,6 +41,7 @@ function NoVideo({
acceptedMessageRequest, acceptedMessageRequest,
avatarPath, avatarPath,
color, color,
type: conversationType,
isMe, isMe,
phoneNumber, phoneNumber,
profileName, profileName,
@ -58,7 +59,7 @@ function NoVideo({
badge={undefined} badge={undefined}
color={color || AvatarColors[0]} color={color || AvatarColors[0]}
noteToSelf={false} noteToSelf={false}
conversationType="direct" conversationType={conversationType}
i18n={i18n} i18n={i18n}
isMe={isMe} isMe={isMe}
phoneNumber={phoneNumber} phoneNumber={phoneNumber}
@ -103,6 +104,10 @@ export function CallingPipRemoteVideo({
return undefined; return undefined;
} }
if (activeCall.joinState !== GroupCallJoinState.Joined) {
return undefined;
}
return maxBy(activeCall.remoteParticipants, participant => return maxBy(activeCall.remoteParticipants, participant =>
participant.presenting ? Infinity : participant.speakerTime || -Infinity participant.presenting ? Infinity : participant.speakerTime || -Infinity
); );