From fb9ca31a43ba2e99d10cc86d767bfea16755d989 Mon Sep 17 00:00:00 2001 From: Gimle Larpes <97182804+GimleLarpes@users.noreply.github.com> Date: Thu, 31 Jul 2025 20:36:16 +0200 Subject: [PATCH 1/3] Update Room.tsx to accomodate restructuring of Room, RoomView and CallView --- src/app/features/room/Room.tsx | 58 +++++++++------------------------- 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/src/app/features/room/Room.tsx b/src/app/features/room/Room.tsx index 24f378b4..e4ecaae7 100644 --- a/src/app/features/room/Room.tsx +++ b/src/app/features/room/Room.tsx @@ -1,4 +1,3 @@ -/* eslint-disable no-nested-ternary */ import React, { useCallback } from 'react'; import { Box, Line } from 'folds'; import { useParams } from 'react-router-dom'; @@ -15,7 +14,6 @@ import { markAsRead } from '../../../client/action/notifications'; import { useMatrixClient } from '../../hooks/useMatrixClient'; import { useRoomMembers } from '../../hooks/useRoomMembers'; import { CallView } from '../call/CallView'; -import { useCallState } from '../../pages/client/call/CallProvider'; import { RoomViewHeader } from './RoomViewHeader'; export function Room() { @@ -25,7 +23,6 @@ export function Room() { const [isDrawer] = useSetting(settingsAtom, 'isPeopleDrawer'); const [hideActivity] = useSetting(settingsAtom, 'hideActivity'); - const { isChatOpen } = useCallState(); const screenSize = useScreenSizeContext(); const powerLevels = usePowerLevels(room); const members = useRoomMembers(mx, room?.roomId); @@ -44,48 +41,23 @@ export function Room() { return ( - - {room.isCallRoom() && } - - - {(!room.isCallRoom() || isChatOpen) && ( - - - - - - )} - {screenSize === ScreenSize.Desktop && !room.isCallRoom() && isDrawer && ( - <> + + + + + + {room.isCallRoom() && screenSize === ScreenSize.Desktop && ( - - - )} + )} + + + {!room.isCallRoom() && screenSize === ScreenSize.Desktop && isDrawer && ( + <> + + + + )} ); From e504a9ef4ce6e8ec04f23b7f56e567cd2dba3d48 Mon Sep 17 00:00:00 2001 From: Gimle Larpes Date: Thu, 31 Jul 2025 20:52:01 +0200 Subject: [PATCH 2/3] Update RoomView.tsx to accomodate restructuring of Room, RoomView and CallView --- src/app/features/room/RoomView.tsx | 116 ++++++++++++++++------------- 1 file changed, 64 insertions(+), 52 deletions(-) diff --git a/src/app/features/room/RoomView.tsx b/src/app/features/room/RoomView.tsx index 25d8fbd8..dd3c5e64 100644 --- a/src/app/features/room/RoomView.tsx +++ b/src/app/features/room/RoomView.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useRef } from 'react'; -import { Box, Text, config } from 'folds'; // Assuming 'folds' is a UI library +import { Box, Text, config, toRem } from 'folds'; import { EventType, Room } from 'matrix-js-sdk'; import { ReactEditor } from 'slate-react'; import { isKeyHotkey } from 'is-hotkey'; @@ -15,7 +15,6 @@ import { RoomTombstone } from './RoomTombstone'; import { RoomInput } from './RoomInput'; import { RoomViewFollowing, RoomViewFollowingPlaceholder } from './RoomViewFollowing'; import { Page } from '../../components/page'; -import { RoomViewHeader } from './RoomViewHeader'; import { useKeyDown } from '../../hooks/useKeyDown'; import { editableActiveElement } from '../../utils/dom'; import navigation from '../../../client/state/navigation'; @@ -23,6 +22,8 @@ import { settingsAtom } from '../../state/settings'; import { useSetting } from '../../state/hooks/settings'; import { useAccessibleTagColors, usePowerLevelTags } from '../../hooks/usePowerLevelTags'; import { useTheme } from '../../hooks/useTheme'; +import { useCallState } from '../../pages/client/call/CallProvider'; +import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize'; const FN_KEYS_REGEX = /^F\d+$/; @@ -64,6 +65,8 @@ export function RoomView({ room, eventId }: { room: Room; eventId?: string }) { const roomInputRef = useRef(null); const roomViewRef = useRef(null); const [hideActivity] = useSetting(settingsAtom, 'hideActivity'); + const screenSize = useScreenSizeContext(); + const { isChatOpen } = useCallState(); const { roomId } = room; const editor = useEditor(); const mx = useMatrixClient(); @@ -98,55 +101,64 @@ export function RoomView({ room, eventId }: { room: Room; eventId?: string }) { ); return ( - - {!room.isCallRoom() && } - - - - - -
- {' '} - {tombstoneEvent ? ( - - ) : ( - <> - {canMessage ? ( - - ) : ( - - You do not have permission to post in this room - - )} - - )} -
- {hideActivity ? : } -
-
+ (!room.isCallRoom() || isChatOpen) && ( + + + + + + +
+ {' '} + {tombstoneEvent ? ( + + ) : ( + /* eslint-disable-next-line react/jsx-no-useless-fragment */ + <> + {canMessage ? ( + + ) : ( + + You do not have permission to post in this room + + )} + + )} +
+ {hideActivity ? : } +
+
+ ) ); } From 528cbc5c79e51ad515192e9db35cfe33da45f339 Mon Sep 17 00:00:00 2001 From: Gimle Larpes Date: Thu, 31 Jul 2025 21:05:15 +0200 Subject: [PATCH 3/3] Update CallView.tsx to accomodate restructuring of Room, RoomView and CallView + suggested changes --- src/app/features/call/CallView.tsx | 39 +++++++++--------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/src/app/features/call/CallView.tsx b/src/app/features/call/CallView.tsx index 516a7909..e5118024 100644 --- a/src/app/features/call/CallView.tsx +++ b/src/app/features/call/CallView.tsx @@ -1,4 +1,3 @@ -/* eslint-disable no-nested-ternary */ import { Room } from 'matrix-js-sdk'; import React, { useContext, useMemo, useCallback, useEffect, useRef } from 'react'; import { Box } from 'folds'; @@ -8,16 +7,7 @@ import { BackupRefContext, } from '../../pages/client/call/PersistentCallContainer'; import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize'; - -function debounce any>(func: F, waitFor: number) { - let timeoutId: ReturnType | null = null; - return (...args: Parameters): void => { - if (timeoutId) { - clearTimeout(timeoutId); - } - timeoutId = setTimeout(() => func(...args), waitFor); - }; -} +import { useDebounce } from '../../hooks/useDebounce'; type OriginalStyles = { position?: string; @@ -45,7 +35,7 @@ export function CallView({ room }: { room: Room }) { ); const screenSize = useScreenSizeContext(); - const isMobile = screenSize === ScreenSize.Mobile; + /* eslint-disable-next-line no-nested-ternary */ const activeIframeDisplayRef = isPrimaryIframe ? isViewingActiveCall ? primaryIframeRef @@ -90,11 +80,10 @@ export function CallView({ room }: { room: Room }) { } }, [activeIframeDisplayRef, room]); - const debouncedApplyFixedPositioning = useCallback(debounce(applyFixedPositioningToIframe, 50), [ - applyFixedPositioningToIframe, - primaryIframeRef, - backupIframeRef, - ]); + const debouncedApplyFixedPositioning = useDebounce(applyFixedPositioningToIframe, { + wait: 50, + immediate: false, + }); useEffect(() => { const iframeElement = activeIframeDisplayRef?.current; const hostElement = iframeHostRef?.current; @@ -103,7 +92,7 @@ export function CallView({ room }: { room: Room }) { applyFixedPositioningToIframe(); const resizeObserver = new ResizeObserver(debouncedApplyFixedPositioning); - resizeObserver.observe(hostElement); + if (hostElement) resizeObserver.observe(hostElement); window.addEventListener('scroll', debouncedApplyFixedPositioning, true); return () => { @@ -121,6 +110,8 @@ export function CallView({ room }: { room: Room }) { originalIframeStylesRef.current = null; }; } + + return undefined; }, [ activeIframeDisplayRef, applyFixedPositioningToIframe, @@ -130,16 +121,10 @@ export function CallView({ room }: { room: Room }) { room, ]); - const isCallViewVisible = room.isCallRoom(); + const isCallViewVisible = room.isCallRoom() && (screenSize === ScreenSize.Desktop || !isChatOpen); return ( - +