clear all room state when rejoining room
This commit is contained in:
parent
8c2ae863fd
commit
7e450071b1
2 changed files with 11 additions and 1 deletions
|
@ -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} =
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright 2020 Bruno Windels <bruno@windels.cloud>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue