Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit d9a20b0

Browse files
authored
Ignore activity in TAC (#12269)
1 parent 6d55ce0 commit d9a20b0

File tree

4 files changed

+36
-60
lines changed

4 files changed

+36
-60
lines changed

src/components/views/spaces/threads-activity-centre/useUnreadThreadRooms.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ function computeUnreadThreadRooms(mxClient: MatrixClient, msc3946ProcessDynamicP
9696
if (VisibilityProvider.instance.isRoomVisible(room) && doesRoomHaveUnreadThreads(room)) {
9797
// Get the greatest notification level of all rooms
9898
const notificationLevel = getThreadNotificationLevel(room);
99+
100+
// If the room has an activity notification or less, we ignore it
101+
if (notificationLevel <= NotificationLevel.Activity) {
102+
continue;
103+
}
104+
99105
if (notificationLevel > greatestNotificationLevel) {
100106
greatestNotificationLevel = notificationLevel;
101107
}

test/components/views/spaces/ThreadsActivityCentre-test.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,13 @@ describe("ThreadsActivityCentre", () => {
111111
expect(getTACMenu()).toBeInTheDocument();
112112
});
113113

114-
it("should render a room with a activity in the TAC", async () => {
114+
it("should not render a room with a activity in the TAC", async () => {
115115
cli.getVisibleRooms = jest.fn().mockReturnValue([roomWithActivity]);
116116
renderTAC();
117117
await userEvent.click(getTACButton());
118118

119-
const tacRows = screen.getAllByRole("menuitem");
120-
expect(tacRows.length).toEqual(1);
121-
122-
getByText(tacRows[0], "Just activity");
123-
expect(tacRows[0].getElementsByClassName("mx_NotificationBadge").length).toEqual(1);
124-
expect(tacRows[0].getElementsByClassName("mx_NotificationBadge_level_notification").length).toEqual(0);
119+
// We should not render the room with activity
120+
expect(() => screen.getAllByRole("menuitem")).toThrow();
125121
});
126122

127123
it("should render a room with a regular notification in the TAC", async () => {

test/components/views/spaces/__snapshots__/ThreadsActivityCentre-test.tsx.snap

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`ThreadsActivityCentre renders notifications matching the snapshot 1`] = `
44
<div
5-
aria-labelledby="radix-13"
5+
aria-labelledby="radix-12"
66
aria-orientation="vertical"
77
class="_menu_1x5h1_17"
88
data-align="end"
@@ -11,7 +11,7 @@ exports[`ThreadsActivityCentre renders notifications matching the snapshot 1`] =
1111
data-side="right"
1212
data-state="open"
1313
dir="ltr"
14-
id="radix-14"
14+
id="radix-13"
1515
role="menu"
1616
style="outline: none; --radix-dropdown-menu-content-transform-origin: var(--radix-popper-transform-origin); --radix-dropdown-menu-content-available-width: var(--radix-popper-available-width); --radix-dropdown-menu-content-available-height: var(--radix-popper-available-height); --radix-dropdown-menu-trigger-width: var(--radix-popper-anchor-width); --radix-dropdown-menu-trigger-height: var(--radix-popper-anchor-height); pointer-events: auto;"
1717
tabindex="-1"
@@ -121,61 +121,13 @@ exports[`ThreadsActivityCentre renders notifications matching the snapshot 1`] =
121121
/>
122122
</div>
123123
</button>
124-
<button
125-
class="mx_ThreadsActivityRow _item_1bcsk_17 _interactive_1bcsk_36"
126-
data-kind="primary"
127-
data-orientation="vertical"
128-
data-radix-collection-item=""
129-
role="menuitem"
130-
tabindex="-1"
131-
>
132-
<div
133-
class="_icon_1bcsk_44"
134-
>
135-
<span
136-
class="_avatar_k41ul_17 mx_BaseAvatar _avatar-imageless_k41ul_60"
137-
data-color="6"
138-
data-testid="avatar-img"
139-
data-type="round"
140-
role="presentation"
141-
style="--cpd-avatar-size: 32px;"
142-
>
143-
J
144-
</span>
145-
</div>
146-
<span
147-
class="_typography_yh5dq_162 _font-body-md-medium_yh5dq_69 _label_1bcsk_53"
148-
>
149-
Just activity
150-
</span>
151-
<svg
152-
aria-hidden="true"
153-
class="_nav-hint_1bcsk_60"
154-
fill="currentColor"
155-
height="24"
156-
viewBox="0 0 24 24"
157-
width="24"
158-
xmlns="http://www.w3.org/2000/svg"
159-
>
160-
<path
161-
d="M8.7 17.3a.948.948 0 0 1-.275-.7.95.95 0 0 1 .275-.7l3.9-3.9-3.9-3.9a.948.948 0 0 1-.275-.7.95.95 0 0 1 .275-.7.948.948 0 0 1 .7-.275.95.95 0 0 1 .7.275l4.6 4.6c.1.1.17.208.213.325.041.117.062.242.062.375s-.02.258-.063.375a.876.876 0 0 1-.212.325l-4.6 4.6a.948.948 0 0 1-.7.275.948.948 0 0 1-.7-.275Z"
162-
/>
163-
</svg>
164-
<div
165-
class="mx_NotificationBadge mx_NotificationBadge_visible mx_NotificationBadge_dot"
166-
>
167-
<span
168-
class="mx_NotificationBadge_count"
169-
/>
170-
</div>
171-
</button>
172124
</div>
173125
</div>
174126
`;
175127

176128
exports[`ThreadsActivityCentre should match snapshot when empty 1`] = `
177129
<div
178-
aria-labelledby="radix-20"
130+
aria-labelledby="radix-18"
179131
aria-orientation="vertical"
180132
class="_menu_1x5h1_17"
181133
data-align="end"
@@ -184,7 +136,7 @@ exports[`ThreadsActivityCentre should match snapshot when empty 1`] = `
184136
data-side="right"
185137
data-state="open"
186138
dir="ltr"
187-
id="radix-21"
139+
id="radix-19"
188140
role="menu"
189141
style="outline: none; --radix-dropdown-menu-content-transform-origin: var(--radix-popper-transform-origin); --radix-dropdown-menu-content-available-width: var(--radix-popper-available-width); --radix-dropdown-menu-content-available-height: var(--radix-popper-available-height); --radix-dropdown-menu-trigger-width: var(--radix-popper-anchor-width); --radix-dropdown-menu-trigger-height: var(--radix-popper-anchor-height); pointer-events: auto;"
190142
tabindex="-1"

test/components/views/spaces/useUnreadThreadRooms-test.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,28 @@ describe("useUnreadThreadRooms", () => {
5151
expect(rooms.length).toEqual(0);
5252
});
5353

54+
it("an activity notification is ignored", async () => {
55+
const notifThreadInfo = await populateThread({
56+
room: room,
57+
client: client,
58+
authorId: "@foo:bar",
59+
participantUserIds: ["@fee:bar"],
60+
});
61+
room.setThreadUnreadNotificationCount(notifThreadInfo.thread.id, NotificationCountType.Total, 0);
62+
63+
client.getVisibleRooms = jest.fn().mockReturnValue([room]);
64+
65+
const wrapper = ({ children }: { children: React.ReactNode }) => (
66+
<MatrixClientContext.Provider value={client}>{children}</MatrixClientContext.Provider>
67+
);
68+
69+
const { result } = renderHook(() => useUnreadThreadRooms(true), { wrapper });
70+
const { greatestNotificationLevel, rooms } = result.current;
71+
72+
expect(greatestNotificationLevel).toBe(NotificationLevel.None);
73+
expect(rooms.length).toEqual(0);
74+
});
75+
5476
it("a notification and a highlight summarise to a highlight", async () => {
5577
const notifThreadInfo = await populateThread({
5678
room: room,
@@ -107,7 +129,7 @@ describe("useUnreadThreadRooms", () => {
107129

108130
const { result } = renderHook(() => useUnreadThreadRooms(true), { wrapper });
109131

110-
expect(result.current.greatestNotificationLevel).toBe(NotificationLevel.Activity);
132+
expect(result.current.greatestNotificationLevel).toBe(NotificationLevel.None);
111133

112134
act(() => {
113135
room.setThreadUnreadNotificationCount(notifThreadInfo.thread.id, NotificationCountType.Highlight, 1);

0 commit comments

Comments
 (0)