mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
chunk is in reverse-chronological order for backward pagination
This commit is contained in:
parent
e3b4f898d0
commit
ef5d2cfa08
@ -43,15 +43,17 @@ export default class GapWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_storeEvents(events, startKey, direction, txn) {
|
_storeEvents(events, startKey, direction, txn) {
|
||||||
const entries = new Array(events.length);
|
const entries = [];
|
||||||
const reducer = direction.isBackward ? Array.prototype.reduceRight : Array.prototype.reduce;
|
// events is in reverse chronological order for backwards pagination,
|
||||||
reducer.call(events, (key, event, i) => {
|
// e.g. order is moving away from the `from` point.
|
||||||
|
let key = startKey;
|
||||||
|
for(let event of events) {
|
||||||
key = key.nextKeyForDirection(direction);
|
key = key.nextKeyForDirection(direction);
|
||||||
const eventEntry = createEventEntry(key, this._roomId, event);
|
const eventStorageEntry = createEventEntry(key, this._roomId, event);
|
||||||
txn.timelineEvents.insert(eventEntry);
|
txn.timelineEvents.insert(eventStorageEntry);
|
||||||
entries[i] = new EventEntry(eventEntry, this._fragmentIdComparer);
|
const eventEntry = new EventEntry(eventStorageEntry, this._fragmentIdComparer);
|
||||||
return key;
|
directionalAppend(entries, eventEntry, direction);
|
||||||
}, startKey);
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user