/* Copyright 2021 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import { CallType } from 'matrix-js-sdk/src/webrtc/call'; import { Room } from 'matrix-js-sdk/src/models/room'; import React from 'react'; import { _t } from '../../../../languageHandler'; import RoomAvatar from '../../avatars/RoomAvatar'; import AccessibleButton from '../../elements/AccessibleButton'; import dis from '../../../../dispatcher/dispatcher'; const callTypeTranslationByType: Record string> = { [CallType.Video]: () => _t("Video Call"), [CallType.Voice]: () => _t("Voice Call"), }; interface CallViewHeaderProps { pipMode: boolean; type: CallType; callRooms?: Room[]; onPipMouseDown: (event: React.MouseEvent) => void; } const onRoomAvatarClick = (roomId: string) => { dis.dispatch({ action: 'view_room', room_id: roomId, }); }; const onFullscreenClick = () => { dis.dispatch({ action: 'video_fullscreen', fullscreen: true, }); }; const onExpandClick = (roomId: string) => { dis.dispatch({ action: 'view_room', room_id: roomId, }); }; type CallControlsProps = Pick & { roomId: string; }; function CallViewHeaderControls({ pipMode = false, type, roomId }: CallControlsProps): JSX.Element { return
{ (pipMode && type === CallType.Video) &&
} { pipMode &&
onExpandClick(roomId)} title={_t("Return to call")} /> }
; } function SecondaryCallInfo({ callRoom }: {callRoom: Room}): JSX.Element { return onRoomAvatarClick(callRoom.roomId)}> { _t("%(name)s on hold", { name: callRoom.name }) } ; } function CallTypeIcon({ type }: {type: CallType}) { const classes = { [CallType.Video]: 'mx_CallView_header_callTypeIcon_video', [CallType.Voice]: 'mx_CallView_header_callTypeIcon_voice', }; const iconClass = classes[type] ?? ''; return
; } export const CallViewHeader: React.FC = ({ type, pipMode = false, callRooms = [], onPipMouseDown, }) => { const [callRoom, onHoldCallRoom] = callRooms; const callTypeText = callTypeTranslationByType[type]; const callRoomName = callRoom.name; const { roomId } = callRoom; if (!pipMode) { return
{ callTypeText }
; } return (
onRoomAvatarClick(roomId)}> ;
{ callRoomName }
{ callTypeText } { onHoldCallRoom && }
); };