From 8fe9db07f68ce18fca34c9c0a4eee26d5edb42fa Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Thu, 13 Aug 2026 14:33:32 +0200 Subject: [PATCH] fix: notify when a message jump fails --- src/app/features/room/RoomTimeline.test.tsx | 14 ++++++++++++++ src/app/features/room/RoomTimeline.tsx | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/app/features/room/RoomTimeline.test.tsx b/src/app/features/room/RoomTimeline.test.tsx index 2e3d49b90..75f5823fc 100644 --- a/src/app/features/room/RoomTimeline.test.tsx +++ b/src/app/features/room/RoomTimeline.test.tsx @@ -30,6 +30,7 @@ const { vListProps, timelineSyncOptions, timelineActionsOptions, + showToastMock, } = vi.hoisted(() => ({ vListHandle: { scrollSize: 1000, @@ -83,6 +84,7 @@ const { vListProps: { shift: false, shiftValues: [] as boolean[] }, timelineSyncOptions: { current: undefined as Record | undefined }, timelineActionsOptions: { current: undefined as Record | undefined }, + showToastMock: vi.fn<(text: string) => void>(), })); let lastOnScroll: ((offset: number) => void) | undefined; @@ -143,6 +145,8 @@ vi.mock('$hooks/useRoomNavigate', () => ({ useRoomNavigate: () => ({ navigateRoom: navigateRoomMock }), })); +vi.mock('$state/toast', () => ({ showToast: showToastMock })); + vi.mock('$hooks/useSpace', () => ({ useSpaceOptionally: () => undefined })); vi.mock('$hooks/useIgnoredUsers', () => ({ useIgnoredUsers: () => [] })); @@ -387,6 +391,7 @@ beforeEach(() => { eventTimeline.current = liveTimeline; liveTimeline.getEvents = () => [{ getId: () => '$evt1' }]; navigateRoomMock.mockReset(); + showToastMock.mockReset(); vListProps.shift = false; vListProps.shiftValues.length = 0; timelineSync.eventsLength = 1; @@ -973,6 +978,15 @@ describe('jump reveal and focus-regain read receipts', () => { expect(queryByText('Jump to Latest')).toBeNull(); }); + it('notifies the user when a jump target cannot be loaded', () => { + render(); + + const onJumpError = timelineSyncOptions.current?.onJumpError as (() => void) | undefined; + act(() => onJumpError?.()); + + expect(showToastMock).toHaveBeenCalledWith('Unable to load this message.'); + }); + it('clears a notification route when an own message returns to the live timeline', async () => { timelineSync.jumpFailed = true; const { getByText, queryByText } = render( diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index 477b5f5d7..d4387716c 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -45,6 +45,7 @@ import { getMemberDisplayName } from '$utils/room/display'; import { useRoomNavigate } from '$hooks/useRoomNavigate'; import { useSlidingSyncRoomLoading } from '$hooks/useSlidingSyncActiveRoom'; import { useOpenUserRoomProfile } from '$state/hooks/userRoomProfile'; +import { showToast } from '$state/toast'; import { useSpaceOptionally } from '$hooks/useSpace'; import { useIgnoredUsers } from '$hooks/useIgnoredUsers'; import { useImagePackRooms } from '$hooks/useImagePackRooms'; @@ -554,6 +555,7 @@ export function RoomTimeline({ const handleJumpError = useCallback(() => { scrollAnchorRef.current = undefined; setAtBottom(true); + showToast('Unable to load this message.'); }, [setAtBottom]); const handleReturnToLive = useCallback(() => { scrollAnchorRef.current = undefined;