need to create archived room when leaving, otherwise it isn't stored
This commit is contained in:
parent
a0e3848cf6
commit
1738a0ea3c
2 changed files with 19 additions and 2 deletions
|
@ -671,6 +671,23 @@ export class Session {
|
||||||
return observable;
|
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) {
|
loadArchivedRoom(roomId, log = null) {
|
||||||
return this._platform.logger.wrapOrRun(log, "loadArchivedRoom", async log => {
|
return this._platform.logger.wrapOrRun(log, "loadArchivedRoom", async log => {
|
||||||
log.set("id", roomId);
|
log.set("id", roomId);
|
||||||
|
|
|
@ -410,12 +410,12 @@ export class Sync {
|
||||||
// when adding a joined room during incremental sync,
|
// when adding a joined room during incremental sync,
|
||||||
// always create the archived room to write the removal
|
// always create the archived room to write the removal
|
||||||
// of the archived summary
|
// of the archived summary
|
||||||
archivedRoom = await this._session.loadArchivedRoom(roomId, log);
|
archivedRoom = this._session.createOrGetArchivedRoomForSync(roomId);
|
||||||
} else if (membership === "leave") {
|
} else if (membership === "leave") {
|
||||||
if (roomState) {
|
if (roomState) {
|
||||||
// we still have a roomState, so we just left it
|
// we still have a roomState, so we just left it
|
||||||
// in this case, create a new archivedRoom
|
// in this case, create a new archivedRoom
|
||||||
archivedRoom = await this._session.loadArchivedRoom(roomId, log);
|
archivedRoom = this._session.createOrGetArchivedRoomForSync(roomId);
|
||||||
} else {
|
} else {
|
||||||
// this is an update of an already left room, restore
|
// this is an update of an already left room, restore
|
||||||
// it from storage first, so we can increment it.
|
// it from storage first, so we can increment it.
|
||||||
|
|
Reference in a new issue