You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-19 16:42:09 +03:00
Set Room.oldState.paginationToken to null at the start of the timeline. Fix linting errors.
This commit is contained in:
@@ -315,7 +315,7 @@ function _sendEvent(client, room, event, callback) {
|
||||
// try to find an event with this event_id. If we find it, this is
|
||||
// the echo of this event *from the event stream* so we can remove
|
||||
// the fake event we made above. If we don't find it, we're still
|
||||
// waiting on the fake event and so should assign the fake event
|
||||
// waiting on the real event and so should assign the fake event
|
||||
// with the real event_id for matching later.
|
||||
var matchingEvent = utils.findElement(room.timeline, function(ev) {
|
||||
return ev.getId() === eventId;
|
||||
@@ -804,11 +804,16 @@ MatrixClient.prototype.roomState = function(roomId, callback) {
|
||||
* @param {Integer} limit Optional. The maximum number of previous events to
|
||||
* pull in. Default: 30.
|
||||
* @param {module:client.callback} callback Optional.
|
||||
* @return {module:client.Promise} Resolves: Room.
|
||||
* @return {module:client.Promise} Resolves: Room. If you are at the beginning
|
||||
* of the timeline, <code>Room.oldState.paginationToken</code> will be
|
||||
* <code>null</code>.
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
MatrixClient.prototype.scrollback = function(room, limit, callback) {
|
||||
if (utils.isFunction(limit)) { callback = limit; limit = undefined; }
|
||||
if (room.oldState.paginationToken === null) {
|
||||
return q(room); // already at the start.
|
||||
}
|
||||
var path = utils.encodeUri(
|
||||
"/rooms/$roomId/messages", {$roomId: room.roomId}
|
||||
);
|
||||
@@ -824,6 +829,9 @@ MatrixClient.prototype.scrollback = function(room, limit, callback) {
|
||||
utils.map(res.chunk, _PojoToMatrixEventMapper), true
|
||||
);
|
||||
room.oldState.paginationToken = res.end;
|
||||
if (res.chunk.length < limit) {
|
||||
room.oldState.paginationToken = null;
|
||||
}
|
||||
_resolve(callback, defer, room);
|
||||
}, function(err) {
|
||||
_reject(callback, defer, err);
|
||||
|
Reference in New Issue
Block a user