forked from mystiq/hydrogen-web
clear all room state before rejoining room
This commit is contained in:
parent
15080edfa7
commit
00d8f81bdd
2 changed files with 14 additions and 2 deletions
|
@ -251,6 +251,9 @@ export class Room extends EventEmitter {
|
|||
log.set("id", this.id);
|
||||
const isRejoin = summaryChanges.membership === "join" && this.membership !== "join";
|
||||
if (isRejoin) {
|
||||
// remove all room state before calling syncWriter,
|
||||
// so no old state sticks around
|
||||
txn.roomState.removeAllForRoom(this.id);
|
||||
this._summary.tryRemoveArchive(txn);
|
||||
}
|
||||
const {entries: newEntries, newLiveKey, memberChanges} =
|
||||
|
|
|
@ -14,17 +14,19 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
const MAX_UNICODE = "\u{10FFFF}";
|
||||
|
||||
export class RoomStateStore {
|
||||
constructor(idbStore) {
|
||||
this._roomStateStore = idbStore;
|
||||
}
|
||||
|
||||
async getAllForType(type) {
|
||||
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
async get(type, stateKey) {
|
||||
|
||||
throw new Error("unimplemented");
|
||||
}
|
||||
|
||||
async set(roomId, event) {
|
||||
|
@ -32,4 +34,11 @@ export class RoomStateStore {
|
|||
const entry = {roomId, event, key};
|
||||
return this._roomStateStore.put(entry);
|
||||
}
|
||||
|
||||
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._roomStateStore.delete(range);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue