need to create archived room when leaving, otherwise it isn't stored

This commit is contained in:
Bruno Windels 2021-05-11 16:58:16 +02:00
parent a0e3848cf6
commit 1738a0ea3c
2 changed files with 19 additions and 2 deletions

View file

@ -671,6 +671,23 @@ export class Session {
return observable;
}
/**
Creates an empty (summary isn't loaded) the archived room if it isn't
loaded already, assuming sync will either remove it (when rejoining) or
write a full summary adopting it from the joined room when leaving
@internal
*/
createOrGetArchivedRoomForSync(roomId) {
let archivedRoom = this._activeArchivedRooms.get(roomId);
if (archivedRoom) {
archivedRoom.retain();
} else {
archivedRoom = this._createArchivedRoom(roomId);
}
return archivedRoom;
}
loadArchivedRoom(roomId, log = null) {
return this._platform.logger.wrapOrRun(log, "loadArchivedRoom", async log => {
log.set("id", roomId);

View file

@ -410,12 +410,12 @@ export class Sync {
// when adding a joined room during incremental sync,
// always create the archived room to write the removal
// of the archived summary
archivedRoom = await this._session.loadArchivedRoom(roomId, log);
archivedRoom = this._session.createOrGetArchivedRoomForSync(roomId);
} else if (membership === "leave") {
if (roomState) {
// we still have a roomState, so we just left it
// in this case, create a new archivedRoom
archivedRoom = await this._session.loadArchivedRoom(roomId, log);
archivedRoom = this._session.createOrGetArchivedRoomForSync(roomId);
} else {
// this is an update of an already left room, restore
// it from storage first, so we can increment it.