diff --git a/src/matrix/room/Room.js b/src/matrix/room/Room.js index 50ffd7a0..375f98c0 100644 --- a/src/matrix/room/Room.js +++ b/src/matrix/room/Room.js @@ -254,6 +254,7 @@ export class Room extends EventEmitter { // remove all room state before calling syncWriter, // so no old state sticks around txn.roomState.removeAllForRoom(this.id); + txn.roomMembers.removeAllForRoom(this.id); txn.archivedRoomSummary.remove(this.id); } const {entries: newEntries, newLiveKey, memberChanges} = diff --git a/src/matrix/storage/idb/stores/RoomMemberStore.js b/src/matrix/storage/idb/stores/RoomMemberStore.js index be2b16ec..340e48a1 100644 --- a/src/matrix/storage/idb/stores/RoomMemberStore.js +++ b/src/matrix/storage/idb/stores/RoomMemberStore.js @@ -1,6 +1,6 @@ /* Copyright 2020 Bruno Windels -Copyright 2020 The Matrix.org Foundation C.I.C. +Copyright 2020, 2021 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ See the License for the specific language governing permissions and limitations under the License. */ +import {MAX_UNICODE} from "./common.js"; + function encodeKey(roomId, userId) { return `${roomId}|${userId}`; } @@ -60,4 +62,11 @@ export class RoomMemberStore { }); return userIds; } + + removeAllForRoom(roomId) { + // exclude both keys as they are theoretical min and max, + // but we should't have a match for just the room id, or room id with max + const range = IDBKeyRange.bound(roomId, `${roomId}|${MAX_UNICODE}`, true, true); + this._roomMembersStore.delete(range); + } }