diff --git a/src/app/features/call/CallView.css.ts b/src/app/features/call/CallView.css.ts index ba1146e2..ef470ca5 100644 --- a/src/app/features/call/CallView.css.ts +++ b/src/app/features/call/CallView.css.ts @@ -3,35 +3,35 @@ import { DefaultReset, config } from 'folds'; import { ContainerColor } from '../../styles/ContainerColor.css'; export const CallViewUserGrid = style({ - display: 'flex', - flexWrap: 'wrap', - justifyContent: 'center', - alignItems: 'center', - marginInline: "20px", - gap: config.space.S400, -}) + display: 'flex', + flexWrap: 'wrap', + justifyContent: 'center', + alignItems: 'center', + marginInline: '20px', + gap: config.space.S400, +}); export const CallViewUser = style([ - DefaultReset, - ContainerColor({ variant: 'SurfaceVariant' }), - { - height: "90px", - width: "150px", - borderRadius: config.radii.R500, - }, -]) + DefaultReset, + ContainerColor({ variant: 'SurfaceVariant' }), + { + height: '90px', + width: '150px', + borderRadius: config.radii.R500, + }, +]); export const UserLink = style({ color: 'inherit', minWidth: 0, cursor: 'pointer', flexGrow: 0, - transition: "all ease-out 200ms", + transition: 'all ease-out 200ms', ':hover': { - transform: "translateY(-3px)", + transform: 'translateY(-3px)', textDecoration: 'unset', }, ':focus': { outline: 'none', }, -}); \ No newline at end of file +}); diff --git a/src/app/features/call/CallView.tsx b/src/app/features/call/CallView.tsx index 1d86dfee..72867001 100644 --- a/src/app/features/call/CallView.tsx +++ b/src/app/features/call/CallView.tsx @@ -1,12 +1,18 @@ import { Room } from 'matrix-js-sdk'; -import React, { useContext, useCallback, useEffect, useRef, MouseEventHandler, useState, ReactNode } from 'react'; +import React, { + useContext, + useCallback, + useEffect, + useRef, + MouseEventHandler, + useState, + ReactNode, +} from 'react'; import { Box, Button, config, Spinner, Text } from 'folds'; import { useCallState } from '../../pages/client/call/CallProvider'; import { useCallMembers } from '../../hooks/useCallMemberships'; -import { - CallRefContext, -} from '../../pages/client/call/PersistentCallContainer'; +import { CallRefContext } from '../../pages/client/call/PersistentCallContainer'; import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize'; import { useDebounce } from '../../hooks/useDebounce'; import { useMatrixClient } from '../../hooks/useMatrixClient'; @@ -14,8 +20,7 @@ import { CallViewUser } from './CallViewUser'; import { useRoomNavigate } from '../../hooks/useRoomNavigate'; import { getMemberDisplayName } from '../../utils/room'; import { getMxIdLocalPart } from '../../utils/matrix'; -import * as css from "./CallView.css" - +import * as css from './CallView.css'; type OriginalStyles = { position?: string; @@ -32,46 +37,51 @@ type OriginalStyles = { export function CallViewUserGrid({ children }: { children: ReactNode }) { return ( - + {children} ); } - export function CallView({ room }: { room: Room }) { const callIframeRef = useContext(CallRefContext); const iframeHostRef = useRef(null); const originalIframeStylesRef = useRef(null); const mx = useMatrixClient(); - - const [visibleCallNames, setVisibleCallNames] = useState("") - const { - isActiveCallReady, - activeCallRoomId, - isChatOpen, - setActiveCallRoomId, - hangUp, - setViewedCallRoomId + const [visibleCallNames, setVisibleCallNames] = useState(''); + + const { + isActiveCallReady, + activeCallRoomId, + isChatOpen, + setActiveCallRoomId, + hangUp, + setViewedCallRoomId, } = useCallState(); - const isActiveCallRoom = activeCallRoomId === room.roomId + const isActiveCallRoom = activeCallRoomId === room.roomId; const callIsCurrentAndReady = isActiveCallRoom && isActiveCallReady; - const callMembers = useCallMembers(mx, room.roomId) + const callMembers = useCallMembers(mx, room.roomId); - const getName = (userId: string) => getMemberDisplayName(room, userId) ?? getMxIdLocalPart(userId); - - const memberDisplayNames = callMembers.map(callMembership => getName(callMembership.sender ?? '')) + const getName = (userId: string) => + getMemberDisplayName(room, userId) ?? getMxIdLocalPart(userId); + + const memberDisplayNames = callMembers.map((callMembership) => + getName(callMembership.sender ?? '') + ); const { navigateRoom } = useRoomNavigate(); const screenSize = useScreenSizeContext(); const isMobile = screenSize === ScreenSize.Mobile; - const activeIframeDisplayRef = callIframeRef + const activeIframeDisplayRef = callIframeRef; const applyFixedPositioningToIframe = useCallback(() => { const iframeElement = activeIframeDisplayRef?.current; @@ -149,31 +159,32 @@ export function CallView({ room }: { room: Room }) { room, ]); - const handleJoinVCClick: MouseEventHandler = (evt) => { - if (isMobile) { - evt.stopPropagation(); - setViewedCallRoomId(room.roomId); - navigateRoom(room.roomId); - } - if (!callIsCurrentAndReady) { - hangUp(); - setActiveCallRoomId(room.roomId); - } + if (isMobile) { + evt.stopPropagation(); + setViewedCallRoomId(room.roomId); + navigateRoom(room.roomId); + } + if (!callIsCurrentAndReady) { + hangUp(); + setActiveCallRoomId(room.roomId); + } }; const isCallViewVisible = room.isCallRoom() && (screenSize === ScreenSize.Desktop || !isChatOpen); useEffect(() => { - if(memberDisplayNames.length <= 2){ - setVisibleCallNames(memberDisplayNames.join(" and ")) + if (memberDisplayNames.length <= 2) { + setVisibleCallNames(memberDisplayNames.join(' and ')); } else { const visible = memberDisplayNames.slice(0, 2); const remaining = memberDisplayNames.length - 2; - setVisibleCallNames(`${visible.join(", ")}, and ${remaining} other${remaining > 1 ? "s" : ""}`) + setVisibleCallNames( + `${visible.join(', ')}, and ${remaining} other${remaining > 1 ? 's' : ''}` + ); } - }, [memberDisplayNames]) + }, [memberDisplayNames]); return ( @@ -187,28 +198,47 @@ export function CallView({ room }: { room: Room }) { display: callIsCurrentAndReady ? 'flex' : 'none', }} /> - + - {callMembers.map(callMember => ( - - )).slice(0, 6)} + {callMembers + .map((callMember) => ) + .slice(0, 6)} - - {room.name} - {visibleCallNames !== "" ? visibleCallNames : "No one"} {memberDisplayNames.length > 1 ? "are" : "is"} currently in voice + + + {room.name} + + + {visibleCallNames !== '' ? visibleCallNames : 'No one'}{' '} + {memberDisplayNames.length > 1 ? 'are' : 'is'} currently in voice + -