mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
fix: notify when a message jump fails (#1770)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Fixes # #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->
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