Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ describe('useRoomNavigation composed entry points', () => {
it('locates and highlights an in-window Message from a Message URL', async () => {
const listRef = makeListRef();
listRef.current.isMessageInWindow.mockReturnValue(true);
mockGetMessageInfo.mockResolvedValue({ id: 'message-1', rid: 'rid-1', ts: 100 });
const messageInfo = { id: 'message-1', rid: 'rid-1', ts: 100 };
mockGetMessageInfo.mockResolvedValue(messageInfo);
mockResolveJumpAnchor.mockResolvedValue(123);
const { result } = renderNavigation({ listContainerRef: listRef });

Expand All @@ -100,7 +101,7 @@ describe('useRoomNavigation composed entry points', () => {

expect(mockResolveJumpAnchor).toHaveBeenCalledWith(
'rid-1',
{ id: 'message-1', tmid: undefined, ts: 100, fromServer: undefined },
messageInfo,
true,
expect.objectContaining({ loadSurroundingMessages: expect.any(Function) })
);
Expand All @@ -111,20 +112,16 @@ describe('useRoomNavigation composed entry points', () => {
it('resolves an out-of-window anchor before requesting the List jump', async () => {
const listRef = makeListRef();
listRef.current.isMessageInWindow.mockReturnValue(false);
mockGetMessageInfo.mockResolvedValue({ id: 'message-2', rid: 'rid-1', ts: 200, fromServer: true });
const messageInfo = { id: 'message-2', rid: 'rid-1', ts: 200, fromServer: true };
mockGetMessageInfo.mockResolvedValue(messageInfo);
mockResolveJumpAnchor.mockResolvedValue(456);
const { result } = renderNavigation({ listContainerRef: listRef });

await act(async () => {
await result.current.jumpToMessageByUrl('https://open.rocket.chat/room?msg=message-2');
});

expect(mockResolveJumpAnchor).toHaveBeenCalledWith(
'rid-1',
expect.objectContaining({ id: 'message-2', fromServer: true }),
false,
expect.any(Object)
);
expect(mockResolveJumpAnchor).toHaveBeenCalledWith('rid-1', messageInfo, false, expect.any(Object));
expect(listRef.current.jumpToMessage).toHaveBeenCalledWith('message-2', 456);
});

Expand Down
7 changes: 1 addition & 6 deletions app/views/RoomView/hooks/useRoomNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,7 @@ export function useRoomNavigation({
return false;
}
const inWindow = listContainerRef.current?.isMessageInWindow(message.id) ?? false;
const highTsMs = await resolveJumpAnchor(
rid,
{ id: message.id, tmid: message.tmid, ts: message.ts, fromServer: message.fromServer },
inWindow,
{ loadSurroundingMessages, getLocalAnchorTs }
);
const highTsMs = await resolveJumpAnchor(rid, message, inWindow, { loadSurroundingMessages, getLocalAnchorTs });
if (!isCurrentJump(generation)) return false;
await waitForFabricCommit();
if (!isCurrentJump(generation)) return false;
Expand Down
Loading