From 783f39c378d30aac3fb3046375881bcad91ff64c Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Sat, 11 May 2019 13:21:21 +0200 Subject: [PATCH] add fragmentId to methods that need it in timeline store --- .../storage/idb/stores/RoomTimelineStore.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/matrix/storage/idb/stores/RoomTimelineStore.js b/src/matrix/storage/idb/stores/RoomTimelineStore.js index 950685d7..0a540dd5 100644 --- a/src/matrix/storage/idb/stores/RoomTimelineStore.js +++ b/src/matrix/storage/idb/stores/RoomTimelineStore.js @@ -105,23 +105,29 @@ export default class RoomTimelineStore { /** Looks up the last `amount` entries in the timeline for `roomId`. * @param {string} roomId + * @param {number} fragmentId * @param {number} amount * @return {Promise} a promise resolving to an array with 0 or more entries, in ascending order. */ - async lastEvents(roomId, amount) { - return this.eventsBefore(roomId, SortKey.maxKey, amount); + async lastEvents(roomId, fragmentId, amount) { + const sortKey = SortKey.maxKey; + sortKey.fragmentId = fragmentId; + return this.eventsBefore(roomId, sortKey, amount); } /** Looks up the first `amount` entries in the timeline for `roomId`. * @param {string} roomId + * @param {number} fragmentId * @param {number} amount * @return {Promise} a promise resolving to an array with 0 or more entries, in ascending order. */ - async firstEvents(roomId, amount) { - return this.eventsAfter(roomId, SortKey.minKey, amount); + async firstEvents(roomId, fragmentId, amount) { + const sortKey = SortKey.minKey; + sortKey.fragmentId = fragmentId; + return this.eventsAfter(roomId, sortKey, amount); } - /** Looks up `amount` entries after `sortKey` in the timeline for `roomId`. + /** Looks up `amount` entries after `sortKey` in the timeline for `roomId` within the same fragment. * The entry for `sortKey` is not included. * @param {string} roomId * @param {SortKey} sortKey @@ -133,7 +139,7 @@ export default class RoomTimelineStore { return this._timelineStore.selectLimit(idbRange, amount); } - /** Looks up `amount` entries before `sortKey` in the timeline for `roomId`. + /** Looks up `amount` entries before `sortKey` in the timeline for `roomId` within the same fragment. * The entry for `sortKey` is not included. * @param {string} roomId * @param {SortKey} sortKey