Start sending stable m.marked_unread events (#28478)

* Start sending stable `m.marked_unread` events

* Update tests
This commit is contained in:
Tulir Asokan 2024-11-18 11:25:36 +01:00 committed by GitHub
parent abf6d58b7b
commit 72a2773629
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 7 additions and 10 deletions

View file

@ -151,10 +151,7 @@ export async function setMarkedUnreadState(room: Room, client: MatrixClient, unr
const currentState = getMarkedUnreadState(room); const currentState = getMarkedUnreadState(room);
if (Boolean(currentState) !== unread) { if (Boolean(currentState) !== unread) {
// Assuming MSC2867 passes FCP with no changes, we should update to start writing await client.setRoomAccountData(room.roomId, MARKED_UNREAD_TYPE_STABLE, { unread });
// the flag to the stable prefix (or both) and then ultimately use only the
// stable prefix.
await client.setRoomAccountData(room.roomId, MARKED_UNREAD_TYPE_UNSTABLE, { unread });
} }
} }

View file

@ -150,7 +150,7 @@ describe("RoomGeneralContextMenu", () => {
await sleep(0); await sleep(0);
expect(mockClient.setRoomAccountData).toHaveBeenCalledWith(ROOM_ID, "com.famedly.marked_unread", { expect(mockClient.setRoomAccountData).toHaveBeenCalledWith(ROOM_ID, "m.marked_unread", {
unread: true, unread: true,
}); });
expect(onFinished).toHaveBeenCalled(); expect(onFinished).toHaveBeenCalled();

View file

@ -338,7 +338,7 @@ describe("RoomViewStore", function () {
}); });
dis.dispatch({ action: Action.ViewRoom, room_id: roomId }); dis.dispatch({ action: Action.ViewRoom, room_id: roomId });
await untilDispatch(Action.ActiveRoomChanged, dis); await untilDispatch(Action.ActiveRoomChanged, dis);
expect(mockClient.setRoomAccountData).toHaveBeenCalledWith(roomId, "com.famedly.marked_unread", { expect(mockClient.setRoomAccountData).toHaveBeenCalledWith(roomId, "m.marked_unread", {
unread: false, unread: false,
}); });
}); });

View file

@ -91,7 +91,7 @@ describe("RoomNotificationState", () => {
const listener = jest.fn(); const listener = jest.fn();
roomNotifState.addListener(NotificationStateEvents.Update, listener); roomNotifState.addListener(NotificationStateEvents.Update, listener);
const accountDataEvent = { const accountDataEvent = {
getType: () => "com.famedly.marked_unread", getType: () => "m.marked_unread",
getContent: () => { getContent: () => {
return { unread: true }; return { unread: true };
}, },

View file

@ -270,7 +270,7 @@ describe("notifications", () => {
// set true, no existing event // set true, no existing event
it("sets unread flag if event doesn't exist", async () => { it("sets unread flag if event doesn't exist", async () => {
await setMarkedUnreadState(room, client, true); await setMarkedUnreadState(room, client, true);
expect(client.setRoomAccountData).toHaveBeenCalledWith(ROOM_ID, "com.famedly.marked_unread", { expect(client.setRoomAccountData).toHaveBeenCalledWith(ROOM_ID, "m.marked_unread", {
unread: true, unread: true,
}); });
}); });
@ -287,7 +287,7 @@ describe("notifications", () => {
.fn() .fn()
.mockReturnValue({ getContent: jest.fn().mockReturnValue({ unread: false }) }); .mockReturnValue({ getContent: jest.fn().mockReturnValue({ unread: false }) });
await setMarkedUnreadState(room, client, true); await setMarkedUnreadState(room, client, true);
expect(client.setRoomAccountData).toHaveBeenCalledWith(ROOM_ID, "com.famedly.marked_unread", { expect(client.setRoomAccountData).toHaveBeenCalledWith(ROOM_ID, "m.marked_unread", {
unread: true, unread: true,
}); });
}); });
@ -316,7 +316,7 @@ describe("notifications", () => {
.fn() .fn()
.mockReturnValue({ getContent: jest.fn().mockReturnValue({ unread: true }) }); .mockReturnValue({ getContent: jest.fn().mockReturnValue({ unread: true }) });
await setMarkedUnreadState(room, client, false); await setMarkedUnreadState(room, client, false);
expect(client.setRoomAccountData).toHaveBeenCalledWith(ROOM_ID, "com.famedly.marked_unread", { expect(client.setRoomAccountData).toHaveBeenCalledWith(ROOM_ID, "m.marked_unread", {
unread: false, unread: false,
}); });
}); });