mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
fix persisting a gappy sync
This commit is contained in:
parent
ef5d2cfa08
commit
c63d94947f
@ -49,7 +49,7 @@ export default class SyncWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _replaceLiveFragment(oldFragmentId, newFragmentId, previousToken, txn) {
|
async _replaceLiveFragment(oldFragmentId, newFragmentId, previousToken, txn) {
|
||||||
const oldFragment = await txn.timelineFragments.get(oldFragmentId);
|
const oldFragment = await txn.timelineFragments.get(this._roomId, oldFragmentId);
|
||||||
if (!oldFragment) {
|
if (!oldFragment) {
|
||||||
throw new Error(`old live fragment doesn't exist: ${oldFragmentId}`);
|
throw new Error(`old live fragment doesn't exist: ${oldFragmentId}`);
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ export default class SyncWriter {
|
|||||||
// replace live fragment for limited sync, *only* if we had a live fragment already
|
// replace live fragment for limited sync, *only* if we had a live fragment already
|
||||||
const oldFragmentId = this._lastLiveKey.fragmentId;
|
const oldFragmentId = this._lastLiveKey.fragmentId;
|
||||||
this._lastLiveKey = this._lastLiveKey.nextFragmentKey();
|
this._lastLiveKey = this._lastLiveKey.nextFragmentKey();
|
||||||
const {oldFragment, newFragment} = this._replaceLiveFragment(oldFragmentId, this._lastLiveKey.fragmentId, timeline.prev_batch, txn);
|
const {oldFragment, newFragment} = await this._replaceLiveFragment(oldFragmentId, this._lastLiveKey.fragmentId, timeline.prev_batch, txn);
|
||||||
entries.push(FragmentBoundaryEntry.end(oldFragment, this._fragmentIdComparer));
|
entries.push(FragmentBoundaryEntry.end(oldFragment, this._fragmentIdComparer));
|
||||||
entries.push(FragmentBoundaryEntry.start(newFragment, this._fragmentIdComparer));
|
entries.push(FragmentBoundaryEntry.start(newFragment, this._fragmentIdComparer));
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ export default class SyncWriter {
|
|||||||
const state = roomResponse.state;
|
const state = roomResponse.state;
|
||||||
if (state.events) {
|
if (state.events) {
|
||||||
for (const event of state.events) {
|
for (const event of state.events) {
|
||||||
txn.roomState.setStateEvent(this._roomId, event)
|
txn.roomState.setStateEvent(this._roomId, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// persist live state events in timeline
|
// persist live state events in timeline
|
||||||
|
Loading…
Reference in New Issue
Block a user