diff --git a/src/client.js b/src/client.js index 9d4e96c83..351eba3e5 100644 --- a/src/client.js +++ b/src/client.js @@ -2112,7 +2112,20 @@ MatrixClient.prototype.getEventTimeline = function(timelineSet, eventId) { return promise; }; -MatrixClient.prototype._createMessagesRequest = function(roomId, fromToken, limit, dir, timelineFilter = undefined) { +/** + * Makes a request to /messages with the appropriate lazy loading filter set. + * XXX: if we do get rid of scrollback (as it's not used at the moment), + * we could inline this method again in paginateEventTimeline as that would + * then be the only call-site + * @param {string} roomId + * @param {string} fromToken + * @param {number} limit the maximum amount of events the retrieve + * @param {string} dir 'f' or 'b' + * @param {Filter} timelineFilter the timeline filter to pass + * @return {Promise} + */ +MatrixClient.prototype._createMessagesRequest = +function(roomId, fromToken, limit, dir, timelineFilter = undefined) { const path = utils.encodeUri( "/rooms/$roomId/messages", {$roomId: roomId}, ); @@ -2139,8 +2152,7 @@ MatrixClient.prototype._createMessagesRequest = function(roomId, fromToken, limi params.filter = JSON.stringify(filter); } return this._http.authedRequest(undefined, "GET", path, params); -} - +}; /** * Take an EventTimeline, and back/forward-fill results. diff --git a/src/models/room-state.js b/src/models/room-state.js index 48f2b68ba..cbabacc1c 100644 --- a/src/models/room-state.js +++ b/src/models/room-state.js @@ -262,15 +262,23 @@ RoomState.prototype.clone = function() { return copy; }; - +/** + * Add previously unknown state events just before + * prepending events to the timeline. + * When lazy loading members while back-paginating, + * the relevant room state for the timeline chunk at the end + * of the chunk can be set with this method. + * @param {MatrixEvent[]} events state events to prepend + */ RoomState.prototype.prependStateEvents = function(events) { const unknownStateEvents = events.filter((event) => { return this.events[event.getType()] === undefined || this.events[event.getType()][event.getStateKey()] === undefined; }); - return this.setStateEvents(unknownStateEvents); -} + this.setStateEvents(unknownStateEvents); +}; + /** * Add an array of one or more state MatrixEvents, overwriting * any existing state with the same {type, stateKey} tuple. Will fire