mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
attempt to load sync writer position when joining a room during sync
since fragments and events are not archived, just the summary, attempt to load the room and sync writer during sync, so we write the timeline correctly and don't cause ConstraintErrors because unaware of fragments and events already there.
This commit is contained in:
parent
07535eedca
commit
9546b13821
@ -223,7 +223,11 @@ export class Sync {
|
||||
return this._storage.readTxn([
|
||||
storeNames.olmSessions,
|
||||
storeNames.inboundGroupSessions,
|
||||
storeNames.timelineEvents // to read events that can now be decrypted
|
||||
// to read fragments when loading sync writer when rejoining archived room
|
||||
storeNames.timelineFragments,
|
||||
// to read fragments when loading sync writer when rejoining archived room
|
||||
// to read events that can now be decrypted
|
||||
storeNames.timelineEvents,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -250,8 +254,13 @@ export class Sync {
|
||||
|
||||
await Promise.all(roomStates.map(async rs => {
|
||||
const newKeys = newKeysByRoom?.get(rs.room.id);
|
||||
rs.preparation = await log.wrap("room", log => rs.room.prepareSync(
|
||||
rs.roomResponse, rs.membership, rs.invite, newKeys, prepareTxn, log), log.level.Detail);
|
||||
rs.preparation = await log.wrap("room", async log => {
|
||||
if (rs.isNewRoom) {
|
||||
await rs.room.load(null, prepareTxn, log);
|
||||
}
|
||||
return rs.room.prepareSync(
|
||||
rs.roomResponse, rs.membership, rs.invite, newKeys, prepareTxn, log)
|
||||
}, log.level.Detail);
|
||||
}));
|
||||
|
||||
// This is needed for safari to not throw TransactionInactiveErrors on the syncTxn. See docs/INDEXEDDB.md
|
||||
|
@ -423,7 +423,10 @@ export class Room extends EventEmitter {
|
||||
async load(summary, txn, log) {
|
||||
log.set("id", this.id);
|
||||
try {
|
||||
this._summary.load(summary);
|
||||
// if called from sync, there is no summary yet
|
||||
if (summary) {
|
||||
this._summary.load(summary);
|
||||
}
|
||||
if (this._summary.data.encryption) {
|
||||
const roomEncryption = this._createRoomEncryption(this, this._summary.data.encryption);
|
||||
this._setEncryption(roomEncryption);
|
||||
@ -714,7 +717,7 @@ export class Room extends EventEmitter {
|
||||
if (this._roomEncryption) {
|
||||
this._timeline.enableEncryption(this._decryptEntries.bind(this, DecryptionSource.Timeline));
|
||||
}
|
||||
await this._timeline.load(this._user, this._summary.data.membership, log);
|
||||
await this._timeline.load(this._user, this.membership, log);
|
||||
return this._timeline;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user