Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Mark as unread not working #32939

Merged
merged 30 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ec9e093
fix: Mark as unread not working
MartinSchoeler Jul 30, 2024
f8c672f
Create hot-balloons-travel.md
MartinSchoeler Jul 30, 2024
e1edd84
test: Mark as unread not working
MartinSchoeler Jul 31, 2024
1500314
Fix order
MartinSchoeler Aug 1, 2024
3022a8d
Merge branch 'develop' into fix/mark-unread
MartinSchoeler Aug 1, 2024
39655aa
revert package removal
MartinSchoeler Aug 2, 2024
6036d88
revert rerouting
MartinSchoeler Aug 2, 2024
d974788
more tests
MartinSchoeler Aug 2, 2024
68b55c3
Update hot-balloons-travel.md
MartinSchoeler Aug 2, 2024
44f6da6
Update mark-unread.spec.ts
MartinSchoeler Aug 2, 2024
617d0aa
reviews
MartinSchoeler Aug 5, 2024
612f9a7
Merge branch 'develop' into fix/mark-unread
MartinSchoeler Aug 12, 2024
83aa653
Merge branch 'develop' into fix/mark-unread
MartinSchoeler Aug 12, 2024
5b2a504
Merge branch 'develop' into fix/mark-unread
MartinSchoeler Aug 13, 2024
3b73135
Merge branch 'develop' into fix/mark-unread
MartinSchoeler Aug 15, 2024
088c967
invalidate sidebar query
MartinSchoeler Aug 29, 2024
2821609
test
MartinSchoeler Aug 29, 2024
6450e28
reveiew
MartinSchoeler Aug 29, 2024
ab63c92
Merge branch 'develop' into fix/mark-unread
MartinSchoeler Aug 29, 2024
e5c54db
fix: review
dougfabris Sep 2, 2024
34060e0
fix: action button
MartinSchoeler Sep 3, 2024
2675fa5
Merge branch 'fix/mark-unread' of https://github.com/RocketChat/Rocke…
MartinSchoeler Sep 3, 2024
809a8a8
fix: e2e test
dougfabris Sep 3, 2024
e406ac6
fix: [gazzo: Gazzo]
MartinSchoeler Sep 3, 2024
f07fcc5
Update hot-balloons-travel.md
MartinSchoeler Sep 3, 2024
4a44af7
Merge remote-tracking branch 'origin/develop' into fix/mark-unread
MartinSchoeler Sep 17, 2024
728ddff
Merge branch 'develop' into fix/mark-unread
scuciatto Sep 17, 2024
a0a1cbb
Merge branch 'develop' into fix/mark-unread
kodiakhq[bot] Sep 18, 2024
c74d20b
Merge branch 'develop' into fix/mark-unread
kodiakhq[bot] Sep 18, 2024
f3db577
Merge branch 'develop' into fix/mark-unread
kodiakhq[bot] Sep 18, 2024
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: 6 additions & 0 deletions .changeset/hot-balloons-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
---

Fixed issue where when you marked a room as read and you were part of it, sometimes it would mark it as read right after
Fixed issue where you were redirected to /home even if you don't have the room open
51 changes: 0 additions & 51 deletions apps/meteor/app/message-mark-as-unread/client/actionButton.ts
MartinSchoeler marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

1 change: 0 additions & 1 deletion apps/meteor/app/message-mark-as-unread/client/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/meteor/client/importPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import '../app/iframe-login/client';
import '../app/license/client';
import '../app/lib/client';
import '../app/livechat-enterprise/client';
import '../app/message-mark-as-unread/client';
import '../app/nextcloud/client';
import '../app/notifications/client';
import '../app/otr/client';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function SideBarItemTemplateWithData({
threadUnread={threadUnread}
rid={rid}
unread={!!unread}
roomOpen={false}
roomOpen={selected}
type={type}
cl={cl}
name={title}
Expand Down
13 changes: 9 additions & 4 deletions apps/meteor/client/sidebar/RoomMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RoomType } from '@rocket.chat/core-typings';
import { Option, Menu } from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useEffectEvent, useMutableCallback } from '@rocket.chat/fuselage-hooks';
import type { TranslationKey, Fields } from '@rocket.chat/ui-contexts';
import {
useRouter,
Expand Down Expand Up @@ -171,19 +171,24 @@ const RoomMenu = ({
);
});

const handleToggleRead = useMutableCallback(async () => {
const handleToggleRead = useEffectEvent(async () => {
try {
if (isUnread) {
await readMessages({ rid, readThreads: true });
return;
}
await unreadMessages(undefined, rid);

if (subscription == null) {
return;
}

LegacyRoomManager.close(subscription.t + subscription.name);

router.navigate('/home');
if (roomOpen) {
router.navigate('/home');
}
MartinSchoeler marked this conversation as resolved.
Show resolved Hide resolved

await unreadMessages(undefined, rid);
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ const SideBarItemTemplateWithData = ({
threadUnread={threadUnread}
rid={rid}
unread={!!unread}
roomOpen={false}
roomOpen={selected}
type={type}
cl={cl}
name={title}
Expand Down
9 changes: 7 additions & 2 deletions apps/meteor/client/sidebarv2/RoomMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,18 @@ const RoomMenu = ({
await readMessages({ rid, readThreads: true });
return;
}
await unreadMessages(undefined, rid);

if (subscription == null) {
return;
}

LegacyRoomManager.close(subscription.t + subscription.name);

router.navigate('/home');
if (roomOpen) {
router.navigate('/home');
}
MartinSchoeler marked this conversation as resolved.
Show resolved Hide resolved

await unreadMessages(undefined, rid);
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
Expand Down
38 changes: 38 additions & 0 deletions apps/meteor/tests/e2e/channels-sidebar.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Users } from './fixtures/userStates';
import { HomeChannel } from './page-objects';
import { createTargetChannel } from './utils';
import { test, expect } from './utils/test';

test.use({ storageState: Users.admin.state });

test.describe.serial('Channels - Sidebar Actions', () => {
let poHomeChannel: HomeChannel;
let targetChannel: string;

test.beforeEach(async ({ page, api }) => {
poHomeChannel = new HomeChannel(page);
await page.emulateMedia({ reducedMotion: 'reduce' });

targetChannel = await createTargetChannel(api);

await page.goto('/home');
});

test.afterEach(async ({ api }) => {
await api.post('/channels.delete', { roomName: targetChannel });
});

test('should not mark empty room as unread', async () => {
// focus should be on the next item
const sidebarItem = await poHomeChannel.sidenav.selectMarkAsUnread(targetChannel);
await expect(sidebarItem.locator('.rcx-badge')).not.toBeVisible();
});

test('should mark a populated room as unread', async () => {
// focus should be on the next item
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.content.sendMessage('this is a message for reply');
const sidebarItem = await poHomeChannel.sidenav.selectMarkAsUnread(targetChannel);
await expect(sidebarItem.locator('.rcx-badge')).toBeVisible();
});
MartinSchoeler marked this conversation as resolved.
Show resolved Hide resolved
});
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ export class HomeSidenav {
return this.page.locator(`[data-qa="sidebar-item"][aria-label="${name}"]`);
}

async selectMarkAsUnread(name: string) {
const sidebarItem = this.getSidebarItemByName(name);
await sidebarItem.focus();
await sidebarItem.locator('.rcx-sidebar-item__menu').click();
await this.page.getByRole('option', { name: 'Mark Unread' }).click();
return sidebarItem;
MartinSchoeler marked this conversation as resolved.
Show resolved Hide resolved
}

async selectPriority(name: string, priority: string) {
const sidebarItem = this.getSidebarItemByName(name);
await sidebarItem.focus();
Expand Down
Loading