From f26d93f1023e289277a0a91c19f8335a70ab513f Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Sat, 25 Jul 2026 20:13:16 +0200 Subject: [PATCH] refactor: give ModalOverlay mobile presentation and android back --- playwright.config.ts | 20 ++- src/app/components/Modal500.tsx | 57 ++------- src/app/components/SwipeableChatWrapper.tsx | 7 +- .../components/SwipeableMessageWrapper.tsx | 7 +- .../components/SwipeableOverlayWrapper.tsx | 7 +- .../attachment-sheet/AttachmentSheet.tsx | 5 +- .../DirectInvitePrompt.tsx | 88 +++++-------- .../join-address-prompt/JoinAddressPrompt.tsx | 97 ++++++--------- .../knock-room-prompt/KnockRoomPrompt.tsx | 117 +++++++----------- .../leave-room-prompt/LeaveRoomPrompt.tsx | 77 +++++------- .../leave-space-prompt/LeaveSpacePrompt.tsx | 116 ++++++++--------- .../components/modal-overlay/ModalOverlay.tsx | 55 +++++++- .../components/modal-overlay/PromptDialog.tsx | 43 +++++++ src/app/components/page/MobileNavDrawer.tsx | 5 +- src/app/components/page/Page.tsx | 5 +- src/app/features/settings/general/General.tsx | 19 +-- src/app/pages/MobileFriendly.tsx | 26 +--- src/app/pages/Router.tsx | 48 ++----- src/app/pages/client/ClientLayout.tsx | 5 +- src/app/state/settings.ts | 2 - 20 files changed, 340 insertions(+), 466 deletions(-) create mode 100644 src/app/components/modal-overlay/PromptDialog.tsx diff --git a/playwright.config.ts b/playwright.config.ts index f5a9587a8..7d214b2f2 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -4,19 +4,27 @@ export default defineConfig({ testDir: './tests/e2e', testMatch: '**/*.spec.ts', snapshotPathTemplate: 'tests/e2e/__screenshots__/{projectName}/{testFileName}/{arg}{ext}', + // Every context shares one Matrix account and device id from the seeded + // storageState, so concurrent clients contend over sync and crypto state. + // Parallelising would need a worker-scoped account fixture; the suite runs in + // well under a minute serially, so it is not worth the plumbing. fullyParallel: false, workers: 1, + // Locally a failure should surface at once; CI keeps retries for flakes. retries: process.env.CI ? 2 : 0, reporter: [['html', { open: 'never' }], ['list']], globalSetup: './tests/e2e/global-setup.ts', + // Tests run in 3-6s against a built app; this is headroom, not a wait budget. timeout: 60_000, expect: { toHaveScreenshot: { maxDiffPixelRatio: 0.01 }, }, use: { - baseURL: 'http://localhost:8080', + baseURL: 'http://localhost:8081', storageState: 'tests/e2e/.auth/state.json', trace: 'on-first-retry', + // Sheets skip their entrance animation here, so a click cannot land mid-slide. + reducedMotion: 'reduce', }, projects: [ { @@ -29,9 +37,15 @@ export default defineConfig({ }, ], webServer: { - command: 'pnpm run build && pnpm exec vite preview --port 8080 --strictPort', - url: 'http://localhost:8080', + // A real build, not the dev server: no HMR and no dependency optimiser, both + // of which invalidate the module graph mid-run and make the suite lie. + // Port 8081, not the dev server's 8080, so a running `pnpm dev` is untouched. + command: 'pnpm run build && pnpm exec vite preview --port 8081 --strictPort', + url: 'http://localhost:8081', + // Never reuse: a leftover server would silently serve a stale build. The + // build is ~30s, which is worth paying to know what is under test. reuseExistingServer: false, + // ~35s observed (31s build + preview start), with headroom for a cold CI box. timeout: 180_000, env: { NODE_OPTIONS: '--max-old-space-size=8192' }, }, diff --git a/src/app/components/Modal500.tsx b/src/app/components/Modal500.tsx index 62fa97c5a..a4951efad 100644 --- a/src/app/components/Modal500.tsx +++ b/src/app/components/Modal500.tsx @@ -1,61 +1,22 @@ import type { ReactNode } from 'react'; import { useRef } from 'react'; -import FocusTrap from 'focus-trap-react'; -import { Modal, Overlay, OverlayBackdrop, OverlayCenter } from 'folds'; -import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize'; -import { stopPropagation } from '$utils/keyboard'; -import { useDismissOnBack } from '$utils/androidBack'; +import { Modal } from 'folds'; +import { ModalOverlay } from '$components/modal-overlay/ModalOverlay'; type Modal500Props = { requestClose: () => void; children: ReactNode; }; + +/** A size-500 modal on desktop that fills the viewport on a phone. */ export function Modal500({ requestClose, children }: Modal500Props) { const modalRef = useRef(null); - const screenSize = useScreenSizeContext(); - - // Android back closes the overlay instead of navigating away. - useDismissOnBack(requestClose); - - if (screenSize === ScreenSize.Mobile) { - return ( - - -
- {children} -
-
-
- ); - } return ( - }> - - modalRef.current ?? document.body, - clickOutsideDeactivates: true, - onDeactivate: requestClose, - escapeDeactivates: stopPropagation, - }} - > - - {children} - - - - + + + {children} + + ); } diff --git a/src/app/components/SwipeableChatWrapper.tsx b/src/app/components/SwipeableChatWrapper.tsx index d0c95801a..5d7d239b8 100644 --- a/src/app/components/SwipeableChatWrapper.tsx +++ b/src/app/components/SwipeableChatWrapper.tsx @@ -17,7 +17,6 @@ export function SwipeableChatWrapper({ onOpenMembers, onReply, }: SwipeableChatWrapperProps) { - const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures'); const [rightSwipeAction] = useSetting(settingsAtom, 'rightSwipeAction'); const x = useMotionValue(0); const containerRef = useRef(null); @@ -57,16 +56,16 @@ export function SwipeableChatWrapper({ useLayoutEffect(() => { const element = containerRef.current; - if (!drawer || !element || !mobileGestures || !mobileOrTablet()) return undefined; + if (!drawer || !element || !mobileOrTablet()) return undefined; return drawer.registerChatSwipe(element, { move, end: ({ distanceX, velocityX }) => finish(true, distanceX, velocityX), cancel: () => finish(false), }); - }, [drawer, finish, mobileGestures, move]); + }, [drawer, finish, move]); - if (!mobileGestures || !mobileOrTablet()) { + if (!mobileOrTablet()) { return (
- settings.mobileGestures && - mobileOrTablet() && - settings.rightSwipeAction !== RightSwipeAction.Members, - [settings.mobileGestures, settings.rightSwipeAction] + () => mobileOrTablet() && settings.rightSwipeAction !== RightSwipeAction.Members, + [settings.rightSwipeAction] ); if (!isSwipeToReplyEnabled || !onReply) { diff --git a/src/app/components/SwipeableOverlayWrapper.tsx b/src/app/components/SwipeableOverlayWrapper.tsx index 87244a37e..3ca276f72 100644 --- a/src/app/components/SwipeableOverlayWrapper.tsx +++ b/src/app/components/SwipeableOverlayWrapper.tsx @@ -1,8 +1,6 @@ import type { ReactNode } from 'react'; import { animate, motion, useMotionValue } from 'framer-motion'; import { useDrag } from '@use-gesture/react'; -import { useSetting } from '$state/hooks/settings'; -import { settingsAtom } from '$state/settings'; import { mobileOrTablet } from '$utils/user-agent'; interface SwipeableOverlayWrapperProps { @@ -16,7 +14,6 @@ export function SwipeableOverlayWrapper({ onClose, direction, }: SwipeableOverlayWrapperProps) { - const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures'); const x = useMotionValue(0); const bind = useDrag( @@ -28,7 +25,7 @@ export function SwipeableOverlayWrapper({ } } - if (!mobileGestures || !mobileOrTablet()) return; + if (!mobileOrTablet()) return; event.stopPropagation(); @@ -68,7 +65,7 @@ export function SwipeableOverlayWrapper({ } ); - if (!mobileGestures || !mobileOrTablet()) { + if (!mobileOrTablet()) { return (
(null); const skipReturnFocusRef = useRef(false); @@ -69,7 +66,7 @@ export function AttachmentSheet({ return true; }, open); - const gesturesEnabled = mobileGestures && mobileOrTablet(); + const gesturesEnabled = mobileOrTablet(); const bind = useDrag( ({ first, active, offset: [, oy], velocity: [, vy], direction: [, dy], event }) => { diff --git a/src/app/components/direct-invite-prompt/DirectInvitePrompt.tsx b/src/app/components/direct-invite-prompt/DirectInvitePrompt.tsx index ead5938df..805cbb0ac 100644 --- a/src/app/components/direct-invite-prompt/DirectInvitePrompt.tsx +++ b/src/app/components/direct-invite-prompt/DirectInvitePrompt.tsx @@ -1,6 +1,5 @@ -import { Box, Button, Dialog, Header, IconButton, Spinner, Text, color, config } from 'folds'; -import { composerIcon, X } from '$components/icons/phosphor'; -import { ModalOverlay } from '$components/modal-overlay/ModalOverlay'; +import { Box, Button, Spinner, Text, color, config } from 'folds'; +import { PromptDialog } from '$components/modal-overlay/PromptDialog'; type DirectInvitePromptProps = { onCancel: () => void; @@ -18,58 +17,39 @@ export function DirectInvitePrompt({ convertError, }: DirectInvitePromptProps) { return ( - - -
- - Invite another Member - - - {composerIcon(X)} - -
- - - - This is a Direct Message room, intended for a conversation between two persons. - Would you like to convert it into a group chat before continuing? + + + + + This is a Direct Message room, intended for a conversation between two persons. + Would you like to convert it into a group chat before continuing? + + {convertError && ( + + Failed to convert direct message to room! {convertError} - {convertError && ( - - Failed to convert direct message to room! {convertError} - - )} - - - - - - + )} -
-
+ + + + + + + ); } diff --git a/src/app/components/join-address-prompt/JoinAddressPrompt.tsx b/src/app/components/join-address-prompt/JoinAddressPrompt.tsx index f1eefb05a..ee293bcb3 100644 --- a/src/app/components/join-address-prompt/JoinAddressPrompt.tsx +++ b/src/app/components/join-address-prompt/JoinAddressPrompt.tsx @@ -1,10 +1,9 @@ import type { FormEventHandler } from 'react'; import { useState } from 'react'; -import { Dialog, Header, config, Box, Text, IconButton, Button, Input, color } from 'folds'; -import { composerIcon, X } from '$components/icons/phosphor'; +import { config, Box, Text, Button, Input, color } from 'folds'; import { isRoomAlias, isRoomId } from '$utils/matrix'; import { parseMatrixToRoom, parseMatrixToRoomEvent, testMatrixTo } from '$plugins/matrix-to'; -import { ModalOverlay } from '$components/modal-overlay/ModalOverlay'; +import { PromptDialog } from '$components/modal-overlay/PromptDialog'; type JoinAddressProps = { onOpen: (roomIdOrAlias: string, via?: string[], eventId?: string) => void; @@ -47,60 +46,44 @@ export function JoinAddressPrompt({ onOpen, onCancel }: JoinAddressProps) { }; return ( - - -
- - Join with Address - - - {composerIcon(X)} - -
- - - - Enter public address to join the community. Addresses looks like: - - -
  • #community:server
  • -
  • https://matrix.to/#/#community:server
  • -
  • https://matrix.to/#/!xYzAj?via=server
  • -
    -
    - - Address - - {invalid && ( - - Invalid Address - - )} - - + + + + + Enter public address to join the community. Addresses looks like: + + +
  • #community:server
  • +
  • https://matrix.to/#/#community:server
  • +
  • https://matrix.to/#/!xYzAj?via=server
  • +
    -
    -
    + + Address + + {invalid && ( + + Invalid Address + + )} + + + + ); } diff --git a/src/app/components/knock-room-prompt/KnockRoomPrompt.tsx b/src/app/components/knock-room-prompt/KnockRoomPrompt.tsx index c31a02704..8718dde05 100644 --- a/src/app/components/knock-room-prompt/KnockRoomPrompt.tsx +++ b/src/app/components/knock-room-prompt/KnockRoomPrompt.tsx @@ -1,24 +1,12 @@ import type { FormEventHandler } from 'react'; import { useCallback, useEffect } from 'react'; -import { - Dialog, - Header, - config, - Box, - Text, - IconButton, - Input, - color, - Button, - Spinner, -} from 'folds'; +import { config, Box, Text, Input, color, Button, Spinner } from 'folds'; import type { MatrixError } from '$types/matrix-sdk'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; -import { composerIcon, X } from '$components/icons/phosphor'; import { createDebugLogger } from '$utils/debugLogger'; -import { ModalOverlay } from '$components/modal-overlay/ModalOverlay'; +import { PromptDialog } from '$components/modal-overlay/PromptDialog'; const debugLog = createDebugLogger('KnockRoomPrompt'); @@ -57,67 +45,50 @@ export function KnockRoomPrompt({ roomId, via, onDone, onCancel }: KnockRoomProp }, [knockState, onDone, roomId]); return ( - - -
    - - Knock On Room - - - {composerIcon(X)} - -
    - - - - Request to join this room. You can optionally leave a reason for the moderators. - - - - Reason{' '} - - (Optional) - + + + + + Request to join this room. You can optionally leave a reason for the moderators. + + + + Reason{' '} + + (Optional) - - {knockState.status === AsyncStatus.Error && ( - - Failed to knock! {knockState.error.message} - - )} - - - + + {knockState.status === AsyncStatus.Error && ( + + Failed to knock! {knockState.error.message} + + )} + -
    -
    + + + ); } diff --git a/src/app/components/leave-room-prompt/LeaveRoomPrompt.tsx b/src/app/components/leave-room-prompt/LeaveRoomPrompt.tsx index 9a457f5a7..5befb2315 100644 --- a/src/app/components/leave-room-prompt/LeaveRoomPrompt.tsx +++ b/src/app/components/leave-room-prompt/LeaveRoomPrompt.tsx @@ -1,10 +1,10 @@ import { useCallback, useEffect } from 'react'; -import { Dialog, Header, config, Box, Text, IconButton, color, Button, Spinner } from 'folds'; +import { config, Box, Text, color, Button, Spinner } from 'folds'; import type { MatrixError } from '$types/matrix-sdk'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; -import { composerIcon, X } from '$components/icons/phosphor'; -import { ModalOverlay } from '$components/modal-overlay/ModalOverlay'; + +import { PromptDialog } from '$components/modal-overlay/PromptDialog'; import { createDebugLogger } from '$utils/debugLogger'; const debugLog = createDebugLogger('LeaveRoomPrompt'); @@ -36,51 +36,34 @@ export function LeaveRoomPrompt({ roomId, onDone, onCancel }: LeaveRoomPromptPro }, [leaveState, onDone, roomId]); return ( - - -
    - - Leave Room - - - {composerIcon(X)} - -
    - - - Are you sure you want to leave this room? - {leaveState.status === AsyncStatus.Error && ( - - Failed to leave room! {leaveState.error.message} - - )} - - + )} -
    -
    + + + ); } diff --git a/src/app/components/leave-space-prompt/LeaveSpacePrompt.tsx b/src/app/components/leave-space-prompt/LeaveSpacePrompt.tsx index ecec11fa2..6abdcc854 100644 --- a/src/app/components/leave-space-prompt/LeaveSpacePrompt.tsx +++ b/src/app/components/leave-space-prompt/LeaveSpacePrompt.tsx @@ -1,12 +1,11 @@ import { useCallback, useEffect, useMemo } from 'react'; -import { Dialog, Header, config, Box, Text, IconButton, color, Button, Spinner } from 'folds'; +import { config, Box, Text, color, Button, Spinner } from 'folds'; import type { MatrixError } from '$types/matrix-sdk'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; -import { composerIcon, X } from '$components/icons/phosphor'; import { getJoinedSpaceChildrenSummary, getRecursiveSpaceLeaveOrder } from '$utils/room'; import { rateLimitedActions } from '$utils/matrix'; -import { ModalOverlay } from '$components/modal-overlay/ModalOverlay'; +import { PromptDialog } from '$components/modal-overlay/PromptDialog'; type LeaveSpacePromptProps = { roomId: string; @@ -77,70 +76,53 @@ export function LeaveSpacePrompt({ roomId, onDone, onCancel }: LeaveSpacePromptP }, [leaveState, leaveAllState, onDone]); return ( - - -
    - - Leave Space - - - {composerIcon(X)} - -
    - - - Are you sure you want to leave this space? - {joinedChildrenCount > 0 && ( - - {formatJoinedContentsMessage(roomCount, subspaceCount)} - - )} - {leaveState.status === AsyncStatus.Error && ( - - Failed to leave space! {leaveState.error.message} - - )} - {leaveAllState.status === AsyncStatus.Error && ( - - Failed to leave space, rooms, and subspaces! {leaveAllState.error.message} - - )} - - - - {joinedChildrenCount > 0 && ( - - )} - + + + + Are you sure you want to leave this space? + {joinedChildrenCount > 0 && ( + + {formatJoinedContentsMessage(roomCount, subspaceCount)} + + )} + {leaveState.status === AsyncStatus.Error && ( + + Failed to leave space! {leaveState.error.message} + + )} + {leaveAllState.status === AsyncStatus.Error && ( + + Failed to leave space, rooms, and subspaces! {leaveAllState.error.message} + + )} -
    -
    + + + {joinedChildrenCount > 0 && ( + + )} + + + ); } diff --git a/src/app/components/modal-overlay/ModalOverlay.tsx b/src/app/components/modal-overlay/ModalOverlay.tsx index bb39d3c65..b5a21230a 100644 --- a/src/app/components/modal-overlay/ModalOverlay.tsx +++ b/src/app/components/modal-overlay/ModalOverlay.tsx @@ -1,22 +1,69 @@ -import type { ReactNode } from 'react'; +import type { ComponentProps, MutableRefObject, ReactNode } from 'react'; import FocusTrap from 'focus-trap-react'; import { Overlay, OverlayBackdrop, OverlayCenter } from 'folds'; +import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize'; import { stopPropagation } from '$utils/keyboard'; +import { useDismissOnBack } from '$utils/androidBack'; + +type FocusTrapOptions = ComponentProps['focusTrapOptions']; type ModalOverlayProps = { open?: boolean; requestClose: () => void; + /** Set false for overlays that must be dismissed deliberately, not by a stray click. */ + dismissOnClickOutside?: boolean; + initialFocus?: FocusTrapOptions['initialFocus']; + /** `fullscreen` drops the centred modal on phones and fills the viewport instead. */ + mobile?: 'centred' | 'fullscreen'; + /** The modal element, used as the focus fallback and as the fullscreen wrapper. */ + contentRef?: MutableRefObject; children: ReactNode; }; -export function ModalOverlay({ open = true, requestClose, children }: ModalOverlayProps) { +export function ModalOverlay({ + open = true, + requestClose, + dismissOnClickOutside = true, + initialFocus = false, + mobile = 'centred', + contentRef, + children, +}: ModalOverlayProps) { + const isMobile = useScreenSizeContext() === ScreenSize.Mobile; + + // Android back closes the overlay instead of navigating away. + useDismissOnBack(requestClose, open); + + if (open && isMobile && mobile === 'fullscreen') { + return ( + + +
    + {children} +
    +
    +
    + ); + } + return ( }> contentRef?.current ?? document.body, + clickOutsideDeactivates: dismissOnClickOutside, onDeactivate: requestClose, escapeDeactivates: stopPropagation, }} diff --git a/src/app/components/modal-overlay/PromptDialog.tsx b/src/app/components/modal-overlay/PromptDialog.tsx new file mode 100644 index 000000000..f4b63984f --- /dev/null +++ b/src/app/components/modal-overlay/PromptDialog.tsx @@ -0,0 +1,43 @@ +import type { ReactNode } from 'react'; +import { Box, Dialog, Header, IconButton, Text, config } from 'folds'; +import { composerIcon, X } from '$components/icons/phosphor'; +import { ModalOverlay } from './ModalOverlay'; + +type PromptDialogProps = { + title: string; + requestClose: () => void; + /** Prompts that must be answered deliberately opt out of click-outside dismiss. */ + dismissOnClickOutside?: boolean; + children: ReactNode; +}; + +/** A titled dialog with a close button, over a dimmed backdrop. */ +export function PromptDialog({ + title, + requestClose, + dismissOnClickOutside, + children, +}: PromptDialogProps) { + return ( + + +
    + + {title} + + + {composerIcon(X)} + +
    + {children} +
    +
    + ); +} diff --git a/src/app/components/page/MobileNavDrawer.tsx b/src/app/components/page/MobileNavDrawer.tsx index ee61d3b6c..368f831ae 100644 --- a/src/app/components/page/MobileNavDrawer.tsx +++ b/src/app/components/page/MobileNavDrawer.tsx @@ -10,8 +10,6 @@ import { } from 'react'; import { useAtomValue, useSetAtom } from 'jotai'; import { matchPath, useLocation, useNavigate } from 'react-router-dom'; -import { useSetting } from '$state/hooks/settings'; -import { settingsAtom } from '$state/settings'; import { lastVisitedRoomAtom } from '$state/room/lastRoom'; import { useReducedMotion } from 'framer-motion'; import { @@ -57,7 +55,6 @@ type ActiveTouchGesture = { /** Sliding mobile drawer with one touch coordinator and a GPU-transformed panel track. */ export function MobileNavDrawer({ nav, rail, bottomNav, children }: MobileNavDrawerProps) { - const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures'); const reduceMotion = useReducedMotion(); const location = useLocation(); const navigate = useNavigate(); @@ -344,7 +341,7 @@ export function MobileNavDrawer({ nav, rail, bottomNav, children }: MobileNavDra onTouchStartCapture={(event) => { const viewport = viewportRef.current; const touch = event.touches[0]; - if (!mobileGestures || !viewport || !touch) return; + if (!viewport || !touch) return; if (event.touches.length !== 1) { finishGesture(true); return; diff --git a/src/app/components/page/Page.tsx b/src/app/components/page/Page.tsx index ae4ab593a..4b43f7b25 100644 --- a/src/app/components/page/Page.tsx +++ b/src/app/components/page/Page.tsx @@ -3,8 +3,6 @@ import { Box, Header, Line, Scroll, Text, as } from 'folds'; import classNames from 'classnames'; import { ContainerColor } from '$styles/ContainerColor.css'; import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize'; -import { useSetting } from '$state/hooks/settings'; -import { settingsAtom } from '$state/settings'; import { MobileNavDrawer } from './MobileNavDrawer'; import * as css from './style.css'; @@ -18,10 +16,9 @@ type PageRootProps = { export function PageRoot({ nav, rail, bottomNav, children, mobileDrawer = true }: PageRootProps) { const screenSize = useScreenSizeContext(); - const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures'); const isMobile = screenSize === ScreenSize.Mobile; - if (isMobile && mobileGestures && mobileDrawer) { + if (isMobile && mobileDrawer) { return ( diff --git a/src/app/features/settings/general/General.tsx b/src/app/features/settings/general/General.tsx index fb0ca47e0..3c8d06bac 100644 --- a/src/app/features/settings/general/General.tsx +++ b/src/app/features/settings/general/General.tsx @@ -963,32 +963,15 @@ function SelectRightSwipeAction({ disabled }: Readonly<{ disabled?: boolean }>) } function Gestures({ isMobile }: Readonly<{ isMobile: boolean }>) { - const [mobileGestures, setMobileGestures] = useSetting(settingsAtom, 'mobileGestures'); - return ( Gestures {!isMobile && '(Mobile Only)'} - - - } - /> - } + after={} /> diff --git a/src/app/pages/MobileFriendly.tsx b/src/app/pages/MobileFriendly.tsx index 772e3513b..e59d2f811 100644 --- a/src/app/pages/MobileFriendly.tsx +++ b/src/app/pages/MobileFriendly.tsx @@ -1,8 +1,6 @@ import type { ReactNode } from 'react'; import { useMatch } from 'react-router-dom'; import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize'; -import { useSetting } from '$state/hooks/settings'; -import { settingsAtom } from '$state/settings'; import { DIRECT_PATH, EXPLORE_PATH, @@ -40,7 +38,6 @@ export function MobileFriendlySidebarNav({ children }: MobileFriendlyClientNavPr export function MobileFriendlyBottomNav({ children }: MobileFriendlyClientNavProps) { const screenSize = useScreenSizeContext(); - const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures'); const homeMatch = useMatch({ path: HOME_PATH, caseSensitive: true, end: true }); const directMatch = useMatch({ path: DIRECT_PATH, caseSensitive: true, end: true }); const spaceMatch = useMatch({ path: SPACE_PATH, caseSensitive: true, end: true }); @@ -52,7 +49,7 @@ export function MobileFriendlyBottomNav({ children }: MobileFriendlyClientNavPro homeMatch || directMatch || spaceMatch || inboxMatch || navigateMatch || profileMatch; if ( screenSize !== ScreenSize.Mobile || - (mobileGestures && !inboxMatch && !navigateMatch && !profileMatch) || + (!inboxMatch && !navigateMatch && !profileMatch) || !onBarDestination || settingsMatch ) { @@ -61,24 +58,3 @@ export function MobileFriendlyBottomNav({ children }: MobileFriendlyClientNavPro return children; } -type MobileFriendlyPageNavProps = { - path: string; - children: ReactNode; -}; -export function MobileFriendlyPageNav({ path, children }: MobileFriendlyPageNavProps) { - const screenSize = useScreenSizeContext(); - const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures'); - const exactPath = useMatch({ - path, - caseSensitive: true, - end: true, - }); - - // With mobile gestures on, the list stays mounted so MobileNavDrawer can reveal it as a - // co-present panel. Without gestures, fall back to the route-based single-view behavior. - if (screenSize === ScreenSize.Mobile && !mobileGestures && !exactPath) { - return null; - } - - return children; -} diff --git a/src/app/pages/Router.tsx b/src/app/pages/Router.tsx index bc2a15cb9..657d13da9 100644 --- a/src/app/pages/Router.tsx +++ b/src/app/pages/Router.tsx @@ -104,11 +104,7 @@ const PublicRooms = lazy(() => import { setAfterLoginRedirectPath } from './afterLoginRedirectPath'; import { WelcomePage } from './client/WelcomePage'; import { SidebarNav } from './client/SidebarNav'; -import { - MobileFriendlyPageNav, - MobileFriendlySidebarNav, - MobileFriendlyBottomNav, -} from './MobileFriendly'; +import { MobileFriendlySidebarNav, MobileFriendlyBottomNav } from './MobileFriendly'; import { ClientInitStorageAtom } from './client/ClientInitStorageAtom'; import { AuthRouteThemeManager, UnAuthRouteThemeManager } from './ThemeManager'; import { TauriDeepLinkBridge } from './TauriDeepLinkBridge'; @@ -293,15 +289,7 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) } - bottomNav={} - nav={ - - - - } - > + } bottomNav={} nav={}> } @@ -323,15 +311,7 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) } - bottomNav={} - nav={ - - - - } - > + } bottomNav={} nav={}> } @@ -354,11 +334,7 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) } bottomNav={} - nav={ - - - - } + nav={} > @@ -398,11 +374,9 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) } nav={ - - {null}}> - - - + {null}}> + + } > @@ -465,11 +439,9 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) element={ - {null}}> - - - + {null}}> + + } > diff --git a/src/app/pages/client/ClientLayout.tsx b/src/app/pages/client/ClientLayout.tsx index a3c93d6fe..01b5bcbf9 100644 --- a/src/app/pages/client/ClientLayout.tsx +++ b/src/app/pages/client/ClientLayout.tsx @@ -2,8 +2,6 @@ import type { ReactNode } from 'react'; import { Box } from 'folds'; import { matchPath, useLocation } from 'react-router-dom'; import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize'; -import { useSetting } from '$state/hooks/settings'; -import { settingsAtom } from '$state/settings'; import { SETTINGS_PATH } from '../paths'; import { isShallowRoute } from './shallowRoute'; @@ -14,12 +12,11 @@ type ClientLayoutProps = { export function ClientLayout({ nav, children }: ClientLayoutProps) { const location = useLocation(); const screenSize = useScreenSizeContext(); - const [mobileGestures] = useSetting(settingsAtom, 'mobileGestures'); const fullPageSettings = Boolean(matchPath(SETTINGS_PATH, location.pathname)) && !isShallowRoute(location.pathname, location.state, screenSize); - const railInDrawer = screenSize === ScreenSize.Mobile && mobileGestures; + const railInDrawer = screenSize === ScreenSize.Mobile; return ( diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index d556df3de..55f4b832c 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -204,7 +204,6 @@ export interface Settings { // Sable features! sendPresence: boolean; - mobileGestures: boolean; rightSwipeAction: RightSwipeAction; hideMembershipInReadOnly: boolean; useRightBubbles: boolean; @@ -383,7 +382,6 @@ export const defaultSettings: Settings = { // Sable features! sendPresence: true, - mobileGestures: true, rightSwipeAction: RightSwipeAction.Reply, hideMembershipInReadOnly: true, useRightBubbles: false,