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

Commit

Permalink
Ignore activity in TAC (#12269)
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros authored Feb 21, 2024
1 parent 6d55ce0 commit d9a20b0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ function computeUnreadThreadRooms(mxClient: MatrixClient, msc3946ProcessDynamicP
if (VisibilityProvider.instance.isRoomVisible(room) && doesRoomHaveUnreadThreads(room)) {
// Get the greatest notification level of all rooms
const notificationLevel = getThreadNotificationLevel(room);

// If the room has an activity notification or less, we ignore it
if (notificationLevel <= NotificationLevel.Activity) {
continue;
}

if (notificationLevel > greatestNotificationLevel) {
greatestNotificationLevel = notificationLevel;
}
Expand Down
10 changes: 3 additions & 7 deletions test/components/views/spaces/ThreadsActivityCentre-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,13 @@ describe("ThreadsActivityCentre", () => {
expect(getTACMenu()).toBeInTheDocument();
});

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

const tacRows = screen.getAllByRole("menuitem");
expect(tacRows.length).toEqual(1);

getByText(tacRows[0], "Just activity");
expect(tacRows[0].getElementsByClassName("mx_NotificationBadge").length).toEqual(1);
expect(tacRows[0].getElementsByClassName("mx_NotificationBadge_level_notification").length).toEqual(0);
// We should not render the room with activity
expect(() => screen.getAllByRole("menuitem")).toThrow();
});

it("should render a room with a regular notification in the TAC", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`ThreadsActivityCentre renders notifications matching the snapshot 1`] = `
<div
aria-labelledby="radix-13"
aria-labelledby="radix-12"
aria-orientation="vertical"
class="_menu_1x5h1_17"
data-align="end"
Expand All @@ -11,7 +11,7 @@ exports[`ThreadsActivityCentre renders notifications matching the snapshot 1`] =
data-side="right"
data-state="open"
dir="ltr"
id="radix-14"
id="radix-13"
role="menu"
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;"
tabindex="-1"
Expand Down Expand Up @@ -121,61 +121,13 @@ exports[`ThreadsActivityCentre renders notifications matching the snapshot 1`] =
/>
</div>
</button>
<button
class="mx_ThreadsActivityRow _item_1bcsk_17 _interactive_1bcsk_36"
data-kind="primary"
data-orientation="vertical"
data-radix-collection-item=""
role="menuitem"
tabindex="-1"
>
<div
class="_icon_1bcsk_44"
>
<span
class="_avatar_k41ul_17 mx_BaseAvatar _avatar-imageless_k41ul_60"
data-color="6"
data-testid="avatar-img"
data-type="round"
role="presentation"
style="--cpd-avatar-size: 32px;"
>
J
</span>
</div>
<span
class="_typography_yh5dq_162 _font-body-md-medium_yh5dq_69 _label_1bcsk_53"
>
Just activity
</span>
<svg
aria-hidden="true"
class="_nav-hint_1bcsk_60"
fill="currentColor"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
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"
/>
</svg>
<div
class="mx_NotificationBadge mx_NotificationBadge_visible mx_NotificationBadge_dot"
>
<span
class="mx_NotificationBadge_count"
/>
</div>
</button>
</div>
</div>
`;

exports[`ThreadsActivityCentre should match snapshot when empty 1`] = `
<div
aria-labelledby="radix-20"
aria-labelledby="radix-18"
aria-orientation="vertical"
class="_menu_1x5h1_17"
data-align="end"
Expand All @@ -184,7 +136,7 @@ exports[`ThreadsActivityCentre should match snapshot when empty 1`] = `
data-side="right"
data-state="open"
dir="ltr"
id="radix-21"
id="radix-19"
role="menu"
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;"
tabindex="-1"
Expand Down
24 changes: 23 additions & 1 deletion test/components/views/spaces/useUnreadThreadRooms-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ describe("useUnreadThreadRooms", () => {
expect(rooms.length).toEqual(0);
});

it("an activity notification is ignored", async () => {
const notifThreadInfo = await populateThread({
room: room,
client: client,
authorId: "@foo:bar",
participantUserIds: ["@fee:bar"],
});
room.setThreadUnreadNotificationCount(notifThreadInfo.thread.id, NotificationCountType.Total, 0);

client.getVisibleRooms = jest.fn().mockReturnValue([room]);

const wrapper = ({ children }: { children: React.ReactNode }) => (
<MatrixClientContext.Provider value={client}>{children}</MatrixClientContext.Provider>
);

const { result } = renderHook(() => useUnreadThreadRooms(true), { wrapper });
const { greatestNotificationLevel, rooms } = result.current;

expect(greatestNotificationLevel).toBe(NotificationLevel.None);
expect(rooms.length).toEqual(0);
});

it("a notification and a highlight summarise to a highlight", async () => {
const notifThreadInfo = await populateThread({
room: room,
Expand Down Expand Up @@ -107,7 +129,7 @@ describe("useUnreadThreadRooms", () => {

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

expect(result.current.greatestNotificationLevel).toBe(NotificationLevel.Activity);
expect(result.current.greatestNotificationLevel).toBe(NotificationLevel.None);

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

0 comments on commit d9a20b0

Please sign in to comment.