mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
small changes
This commit is contained in:
parent
d6857a1ede
commit
511e91a699
@ -19,12 +19,6 @@ class RoomPersister {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async persistSync(roomResponse, txn) {
|
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;
|
let nextKey;
|
||||||
const timeline = roomResponse.timeline;
|
const timeline = roomResponse.timeline;
|
||||||
@ -34,6 +28,7 @@ class RoomPersister {
|
|||||||
txn.timeline.appendGap(this._roomId, nextKey, {prev_batch: timeline.prev_batch});
|
txn.timeline.appendGap(this._roomId, nextKey, {prev_batch: timeline.prev_batch});
|
||||||
}
|
}
|
||||||
nextKey = this._lastSortKey.nextKey();
|
nextKey = this._lastSortKey.nextKey();
|
||||||
|
const startOfChunkSortKey = nextKey;
|
||||||
|
|
||||||
if (timeline.events) {
|
if (timeline.events) {
|
||||||
for(const event of timeline.events) {
|
for(const event of timeline.events) {
|
||||||
@ -43,5 +38,14 @@ class RoomPersister {
|
|||||||
}
|
}
|
||||||
// what happens here when the txn fails?
|
// what happens here when the txn fails?
|
||||||
this._lastSortKey = nextKey;
|
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) => {
|
parseRooms(response.rooms, async (roomId, roomResponse, membership) => {
|
||||||
let room = session.getRoom(roomId);
|
let room = session.getRoom(roomId);
|
||||||
if (!room) {
|
if (!room) {
|
||||||
room = session.createRoom(roomId, txn);
|
room = session.createRoom(roomId);
|
||||||
}
|
}
|
||||||
room.applySync(roomResponse, membership, txn);
|
room.applySync(roomResponse, membership, txn);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user