mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
fix: notify when a message jump fails
This commit is contained in:
2 files changed
+16
No files matched your search
@@ -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<string, unknown> | undefined },
|
||||
timelineActionsOptions: { current: undefined as Record<string, unknown> | 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(<RoomTimeline room={room} editor={{} as Editor} eventId="$missing:example.org" />);
|
||||
|
||||
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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user