2021-01-14 18:07:05 +00:00
|
|
|
// Copyright 2020-2021 Signal Messenger, LLC
|
2020-11-13 19:57:55 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import React, { useRef, useEffect } from 'react';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { SetRendererCanvasType } from '../state/ducks/calling';
|
|
|
|
import type { ConversationType } from '../state/ducks/conversations';
|
|
|
|
import type { LocalizerType } from '../types/Util';
|
2021-08-06 00:17:05 +00:00
|
|
|
import { AvatarColors } from '../types/Colors';
|
2020-11-13 19:57:55 +00:00
|
|
|
import { Avatar } from './Avatar';
|
|
|
|
|
2021-01-14 18:07:05 +00:00
|
|
|
type PropsType = {
|
2020-11-13 19:57:55 +00:00
|
|
|
conversation: ConversationType;
|
|
|
|
hasRemoteVideo: boolean;
|
|
|
|
i18n: LocalizerType;
|
|
|
|
setRendererCanvas: (_: SetRendererCanvasType) => void;
|
2021-01-14 18:07:05 +00:00
|
|
|
};
|
2020-11-13 19:57:55 +00:00
|
|
|
|
|
|
|
export const DirectCallRemoteParticipant: React.FC<PropsType> = ({
|
|
|
|
conversation,
|
|
|
|
hasRemoteVideo,
|
|
|
|
i18n,
|
|
|
|
setRendererCanvas,
|
|
|
|
}) => {
|
|
|
|
const remoteVideoRef = useRef<HTMLCanvasElement | null>(null);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
setRendererCanvas({ element: remoteVideoRef });
|
|
|
|
return () => {
|
|
|
|
setRendererCanvas({ element: undefined });
|
|
|
|
};
|
|
|
|
}, [setRendererCanvas]);
|
|
|
|
|
|
|
|
return hasRemoteVideo ? (
|
|
|
|
<canvas
|
|
|
|
className="module-ongoing-call__remote-video-enabled"
|
|
|
|
ref={remoteVideoRef}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
renderAvatar(i18n, conversation)
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
function renderAvatar(
|
|
|
|
i18n: LocalizerType,
|
|
|
|
{
|
2021-05-07 22:21:10 +00:00
|
|
|
acceptedMessageRequest,
|
2020-11-13 19:57:55 +00:00
|
|
|
avatarPath,
|
|
|
|
color,
|
2021-05-07 22:21:10 +00:00
|
|
|
isMe,
|
2020-11-13 19:57:55 +00:00
|
|
|
name,
|
|
|
|
phoneNumber,
|
|
|
|
profileName,
|
2021-05-07 22:21:10 +00:00
|
|
|
sharedGroupNames,
|
2020-11-13 19:57:55 +00:00
|
|
|
title,
|
2021-05-07 22:21:10 +00:00
|
|
|
}: Pick<
|
|
|
|
ConversationType,
|
|
|
|
| 'acceptedMessageRequest'
|
|
|
|
| 'avatarPath'
|
|
|
|
| 'color'
|
|
|
|
| 'isMe'
|
|
|
|
| 'name'
|
|
|
|
| 'phoneNumber'
|
|
|
|
| 'profileName'
|
|
|
|
| 'sharedGroupNames'
|
|
|
|
| 'title'
|
|
|
|
>
|
2020-11-13 19:57:55 +00:00
|
|
|
): JSX.Element {
|
|
|
|
return (
|
|
|
|
<div className="module-ongoing-call__remote-video-disabled">
|
|
|
|
<Avatar
|
2021-05-07 22:21:10 +00:00
|
|
|
acceptedMessageRequest={acceptedMessageRequest}
|
2020-11-13 19:57:55 +00:00
|
|
|
avatarPath={avatarPath}
|
2021-12-01 17:24:00 +00:00
|
|
|
badge={undefined}
|
2021-08-06 00:17:05 +00:00
|
|
|
color={color || AvatarColors[0]}
|
2020-11-13 19:57:55 +00:00
|
|
|
noteToSelf={false}
|
|
|
|
conversationType="direct"
|
|
|
|
i18n={i18n}
|
2021-05-07 22:21:10 +00:00
|
|
|
isMe={isMe}
|
2020-11-13 19:57:55 +00:00
|
|
|
name={name}
|
|
|
|
phoneNumber={phoneNumber}
|
|
|
|
profileName={profileName}
|
|
|
|
title={title}
|
2021-05-07 22:21:10 +00:00
|
|
|
sharedGroupNames={sharedGroupNames}
|
2020-11-13 19:57:55 +00:00
|
|
|
size={112}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|