1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-28 15:22:05 +03:00

Add labs flag for Threads Activity Centre (#12137)

* Add `Thread Activity centre` labs flag

* Rename translation string

* Update supportedLevels

* Fix labs subsection test

* Update Threads Activity Centre label

* Make threads activity centre labs flag split out unread counts

Just shows notif & unread counts for main thread if the TAC is enabled.

* Fix tests

* Simpler fix

* Pass in & cache the status of the TAC labs flag

* Pass includeThreads as setting to doesRoomHaveUnreadMessages too

* Fix tests

---------

Co-authored-by: David Baker <dbkr@users.noreply.github.com>
This commit is contained in:
Florian Duros
2024-01-29 18:52:48 +01:00
committed by GitHub
parent a370a5cfa4
commit 77e1649f0b
15 changed files with 111 additions and 56 deletions

View File

@ -152,7 +152,7 @@ describe("Unread", () => {
});
it("returns true for a room with no receipts", () => {
expect(doesRoomHaveUnreadMessages(room)).toBe(true);
expect(doesRoomHaveUnreadMessages(room, false)).toBe(true);
});
it("returns false for a room when the latest event was sent by the current user", () => {
@ -166,7 +166,7 @@ describe("Unread", () => {
// Only for timeline events.
room.addLiveEvents([event]);
expect(doesRoomHaveUnreadMessages(room)).toBe(false);
expect(doesRoomHaveUnreadMessages(room, false)).toBe(false);
});
it("returns false for a room when the read receipt is at the latest event", () => {
@ -183,7 +183,7 @@ describe("Unread", () => {
});
room.addReceipt(receipt);
expect(doesRoomHaveUnreadMessages(room)).toBe(false);
expect(doesRoomHaveUnreadMessages(room, false)).toBe(false);
});
it("returns true for a room when the read receipt is earlier than the latest event", () => {
@ -210,7 +210,7 @@ describe("Unread", () => {
// Only for timeline events.
room.addLiveEvents([event2]);
expect(doesRoomHaveUnreadMessages(room)).toBe(true);
expect(doesRoomHaveUnreadMessages(room, false)).toBe(true);
});
it("returns true for a room with an unread message in a thread", async () => {
@ -247,7 +247,7 @@ describe("Unread", () => {
// Create a thread as a different user.
await populateThread({ room, client, authorId: myId, participantUserIds: [aliceId] });
expect(doesRoomHaveUnreadMessages(room)).toBe(true);
expect(doesRoomHaveUnreadMessages(room, true)).toBe(true);
});
it("returns false for a room when the latest thread event was sent by the current user", async () => {
@ -268,7 +268,7 @@ describe("Unread", () => {
// Create a thread as the current user.
await populateThread({ room, client, authorId: myId, participantUserIds: [myId] });
expect(doesRoomHaveUnreadMessages(room)).toBe(false);
expect(doesRoomHaveUnreadMessages(room, true)).toBe(false);
});
it("returns false for a room with read thread messages", async () => {
@ -308,7 +308,7 @@ describe("Unread", () => {
});
room.addReceipt(receipt);
expect(doesRoomHaveUnreadMessages(room)).toBe(false);
expect(doesRoomHaveUnreadMessages(room, true)).toBe(false);
});
it("returns true for a room when read receipt is not on the latest thread messages", async () => {
@ -348,7 +348,7 @@ describe("Unread", () => {
});
room.addReceipt(receipt);
expect(doesRoomHaveUnreadMessages(room)).toBe(true);
expect(doesRoomHaveUnreadMessages(room, true)).toBe(true);
});
it("returns true when the event for a thread receipt can't be found", async () => {
@ -394,7 +394,7 @@ describe("Unread", () => {
});
room.addReceipt(receipt);
expect(doesRoomHaveUnreadMessages(room)).toBe(true);
expect(doesRoomHaveUnreadMessages(room, true)).toBe(true);
});
});
@ -412,7 +412,7 @@ describe("Unread", () => {
// Only for timeline events.
room.addLiveEvents([redactedEvent]);
expect(doesRoomHaveUnreadMessages(room)).toBe(true);
expect(doesRoomHaveUnreadMessages(room, true)).toBe(true);
expect(logger.warn).toHaveBeenCalledWith(
"Falling back to unread room because of no read receipt or counting message found",
{