RLS: Remove forgotten room from skiplist (#29933)

* Dispatch an action when room is forgotten

* Dispatch an action when room is forgotten

* Remove room on action

* Add test

* Write test for matrixchat

* Add payload info to comment
This commit is contained in:
R Midhun Suresh
2025-05-15 15:34:05 +05:30
committed by GitHub
parent aef3c8e986
commit 57d3b2d93c
6 changed files with 89 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ import { SortingAlgorithm } from "../../../../src/stores/room-list-v3/skip-list/
import SettingsStore from "../../../../src/settings/SettingsStore";
import * as utils from "../../../../src/utils/notifications";
import * as roomMute from "../../../../src/stores/room-list/utils/roomMute";
import { Action } from "../../../../src/dispatcher/actions";
describe("RoomListStoreV3", () => {
async function getRoomListStore() {
@@ -121,6 +122,27 @@ describe("RoomListStoreV3", () => {
expect(store.getSortedRooms()[0].roomId).toEqual(room.roomId);
});
it("Forgotten room is removed", async () => {
const { store, rooms, dispatcher } = await getRoomListStore();
const room = rooms[37];
// Room at index 37 should be in the store now
expect(store.getSortedRooms().map((r) => r.roomId)).toContain(room.roomId);
// Forget room at index 37
const payload = {
action: Action.AfterForgetRoom,
room: room,
};
const fn = jest.fn();
store.on(LISTS_UPDATE_EVENT, fn);
dispatcher.dispatch(payload, true);
// Room at index 37 should no longer be in the store
expect(fn).toHaveBeenCalled();
expect(store.getSortedRooms().map((r) => r.roomId)).not.toContain(room.roomId);
});
it.each([KnownMembership.Join, KnownMembership.Invite])(
"Room is removed when membership changes to leave",
async (membership) => {