1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

cleanup, lint and docs

This commit is contained in:
Bruno Windels
2018-08-02 19:49:24 +02:00
parent 52149ce74a
commit 01d8730850
2 changed files with 26 additions and 6 deletions

View File

@@ -2112,7 +2112,20 @@ MatrixClient.prototype.getEventTimeline = function(timelineSet, eventId) {
return promise; 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( const path = utils.encodeUri(
"/rooms/$roomId/messages", {$roomId: roomId}, "/rooms/$roomId/messages", {$roomId: roomId},
); );
@@ -2139,8 +2152,7 @@ MatrixClient.prototype._createMessagesRequest = function(roomId, fromToken, limi
params.filter = JSON.stringify(filter); params.filter = JSON.stringify(filter);
} }
return this._http.authedRequest(undefined, "GET", path, params); return this._http.authedRequest(undefined, "GET", path, params);
} };
/** /**
* Take an EventTimeline, and back/forward-fill results. * Take an EventTimeline, and back/forward-fill results.

View File

@@ -262,15 +262,23 @@ RoomState.prototype.clone = function() {
return copy; 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) { RoomState.prototype.prependStateEvents = function(events) {
const unknownStateEvents = events.filter((event) => { const unknownStateEvents = events.filter((event) => {
return this.events[event.getType()] === undefined || return this.events[event.getType()] === undefined ||
this.events[event.getType()][event.getStateKey()] === 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 * Add an array of one or more state MatrixEvents, overwriting
* any existing state with the same {type, stateKey} tuple. Will fire * any existing state with the same {type, stateKey} tuple. Will fire