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
6 changes: 4 additions & 2 deletions apps/meteor/client/views/room/body/hooks/useUnreadMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ export const useHandleUnread = (
return;
}
setMessageJumpQueryStringParameter(message?._id);
chat.readStateManager.markAsRead();
Copy link
Member Author

@abhinavkrin abhinavkrin Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed to be a fix for me. While clicking on the banner, It would take me to message. But when page is refreshed, the banner would reapper.

setUnreadCount(0);
}, [room._id, setUnreadCount, findFirstMessage, unread?.since]);
}, [room._id, setUnreadCount, findFirstMessage, unread?.since, chat.readStateManager]);

const handleMarkAsReadButtonClick = useCallback(() => {
chat.readStateManager.markAsRead();
Expand All @@ -91,7 +92,8 @@ export const useHandleUnread = (
const count = filterMessages(
(record) =>
record.rid === room._id &&
record.ts.getTime() <= (lastMessageDate?.getTime() ?? Infinity) &&
!!lastMessageDate &&
record.ts.getTime() <= lastMessageDate?.getTime() &&
record.ts.getTime() > (subscription?.ls?.getTime() ?? -Infinity),
).length;

Expand Down
14 changes: 13 additions & 1 deletion apps/meteor/tests/e2e/threads.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Users } from './fixtures/userStates';
import { HomeChannel } from './page-objects';
import { createTargetChannel } from './utils';
import { createTargetChannel, deleteChannel } from './utils';
import { expect, test } from './utils/test';

test.use({ storageState: Users.admin.state });
Expand All @@ -15,6 +15,18 @@ test.describe.serial('Threads', () => {
await page.goto('/home');
await poHomeChannel.sidenav.openChat(targetChannel);
});

test.afterAll(async ({ api }) => deleteChannel(api, targetChannel));

test('expect no unread banner when replying to a thread in a fresh channel', async ({ page }) => {
await poHomeChannel.content.sendMessage('parent for unread-banner test');
await poHomeChannel.content.openReplyInThread();
await poHomeChannel.content.sendMessageInThread('first thread reply');

await page.waitForTimeout(200);
await expect(page.getByTitle('Mark as read')).not.toBeVisible();
});

test('expect thread message preview if alsoSendToChannel checkbox is checked', async ({ page }) => {
await poHomeChannel.content.sendMessage('this is a message for reply');
await page.locator('[data-qa-type="message"]').last().hover();
Expand Down
Loading