small changes
This commit is contained in:
parent
d6857a1ede
commit
511e91a699
2 changed files with 11 additions and 7 deletions
|
@ -19,12 +19,6 @@ class RoomPersister {
|
|||
}
|
||||
|
||||
async persistSync(roomResponse, txn) {
|
||||
// persist state
|
||||
const state = roomResponse.state;
|
||||
if (state.events) {
|
||||
const promises = state.events.map((event) => txn.state.setStateEventAt(this._lastSortKey, event));
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
let nextKey;
|
||||
const timeline = roomResponse.timeline;
|
||||
|
@ -34,6 +28,7 @@ class RoomPersister {
|
|||
txn.timeline.appendGap(this._roomId, nextKey, {prev_batch: timeline.prev_batch});
|
||||
}
|
||||
nextKey = this._lastSortKey.nextKey();
|
||||
const startOfChunkSortKey = nextKey;
|
||||
|
||||
if (timeline.events) {
|
||||
for(const event of timeline.events) {
|
||||
|
@ -43,5 +38,14 @@ class RoomPersister {
|
|||
}
|
||||
// what happens here when the txn fails?
|
||||
this._lastSortKey = nextKey;
|
||||
|
||||
// persist state
|
||||
const state = roomResponse.state;
|
||||
if (state.events) {
|
||||
const promises = state.events.map((event) => {
|
||||
txn.state.setStateEventAt(startOfChunkSortKey, event)
|
||||
});
|
||||
await Promise.all(promises);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -75,7 +75,7 @@ export class Sync {
|
|||
parseRooms(response.rooms, async (roomId, roomResponse, membership) => {
|
||||
let room = session.getRoom(roomId);
|
||||
if (!room) {
|
||||
room = session.createRoom(roomId, txn);
|
||||
room = session.createRoom(roomId);
|
||||
}
|
||||
room.applySync(roomResponse, membership, txn);
|
||||
});
|
||||
|
|
Reference in a new issue