mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
get live fragment in persister
This commit is contained in:
parent
783f39c378
commit
41f2224454
@ -33,18 +33,21 @@ export default class RoomPersister {
|
|||||||
this._storage = storage;
|
this._storage = storage;
|
||||||
// TODO: load fragmentIndex?
|
// TODO: load fragmentIndex?
|
||||||
this._lastSortKey = new SortKey();
|
this._lastSortKey = new SortKey();
|
||||||
|
this._lastSortKey = null;
|
||||||
|
this._fragmentIdIndex = new FragmentIdIndex([]); //only used when timeline is loaded ... e.g. "certain" methods on this class... split up?
|
||||||
}
|
}
|
||||||
|
|
||||||
async load(txn) {
|
async load(txn) {
|
||||||
//fetch key here instead?
|
const liveFragment = await txn.roomFragments.liveFragment(this._roomId);
|
||||||
const [lastEvent] = await txn.roomTimeline.lastEvents(this._roomId, 1);
|
if (liveFragment) {
|
||||||
if (lastEvent) {
|
const [lastEvent] = await txn.roomTimeline.lastEvents(this._roomId, liveFragment.id, 1);
|
||||||
// TODO: load fragmentIndex?
|
// last event needs to come from the fragment (e.g. passing the last fragment id)
|
||||||
this._lastSortKey = new SortKey(lastEvent.sortKey);
|
const lastSortKey = new SortKey(this._fragmentIdIndex);
|
||||||
console.log("room persister load", this._roomId, this._lastSortKey.toString());
|
lastSortKey.fragmentId = liveFragment.id;
|
||||||
} else {
|
lastSortKey.eventIndex = lastEvent.eventIndex;
|
||||||
console.warn("could not recover last sort key for ", this._roomId);
|
this._lastSortKey = lastSortKey;
|
||||||
}
|
}
|
||||||
|
console.log("room persister load", this._roomId, this._lastSortKey && this._lastSortKey.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
async persistGapFill(gapEntry, response) {
|
async persistGapFill(gapEntry, response) {
|
||||||
|
Loading…
Reference in New Issue
Block a user