diff --git a/src/stores/room-list-v3/RoomListStoreV3.ts b/src/stores/room-list-v3/RoomListStoreV3.ts index e0461c3a5f..6133fcfd19 100644 --- a/src/stores/room-list-v3/RoomListStoreV3.ts +++ b/src/stores/room-list-v3/RoomListStoreV3.ts @@ -260,7 +260,7 @@ export class RoomListStoreV3Class extends AsyncStoreWithClient { } } - this.addRoomAndEmit(payload.room, true); + this.addRoomAndEmit(payload.room, oldMembership === EffectiveMembership.Leave); break; } diff --git a/test/unit-tests/stores/room-list-v3/RoomListStoreV3-test.ts b/test/unit-tests/stores/room-list-v3/RoomListStoreV3-test.ts index 78ec98e02e..2d7dd4459c 100644 --- a/test/unit-tests/stores/room-list-v3/RoomListStoreV3-test.ts +++ b/test/unit-tests/stores/room-list-v3/RoomListStoreV3-test.ts @@ -29,6 +29,7 @@ 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"; +import { SettingLevel } from "../../../../src/settings/SettingLevel.ts"; describe("RoomListStoreV3", () => { async function getRoomListStore() { @@ -218,7 +219,6 @@ describe("RoomListStoreV3", () => { dispatcher.dispatch( { action: "MatrixActions.Room.myMembership", - oldMembership: KnownMembership.Invite, membership: KnownMembership.Join, room: newRoom, }, @@ -253,7 +253,6 @@ describe("RoomListStoreV3", () => { dispatcher.dispatch( { action: "MatrixActions.Room.myMembership", - oldMembership: KnownMembership.Invite, membership: KnownMembership.Join, room: newRoom, }, @@ -759,6 +758,35 @@ describe("RoomListStoreV3", () => { expect(result).toHaveLength(1); expect(result).toContain(rooms[8]); }); + + it("should update filters on membership change", async () => { + await SettingsStore.setValue("feature_ask_to_join", null, SettingLevel.DEVICE, true); + const { store, client, dispatcher } = await getRoomListStore(); + const room = new Room("!fooknock:matrix.org", client, client.getSafeUserId(), {}); + + room.getMyMembership = jest.fn().mockReturnValue(KnownMembership.Knock); + dispatcher.dispatch( + { + action: "MatrixActions.Room.myMembership", + membership: KnownMembership.Knock, + room, + }, + true, + ); + expect(store.getSortedRoomsInActiveSpace([FilterKey.InvitesFilter]).rooms).not.toContain(room); + + room.getMyMembership = jest.fn().mockReturnValue(KnownMembership.Invite); + dispatcher.dispatch( + { + action: "MatrixActions.Room.myMembership", + oldMembership: KnownMembership.Knock, + membership: KnownMembership.Invite, + room, + }, + true, + ); + expect(store.getSortedRoomsInActiveSpace([FilterKey.InvitesFilter]).rooms).toContain(room); + }); }); });