You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
initial support for lazy loading when calling /context
This commit is contained in:
@@ -2067,11 +2067,16 @@ MatrixClient.prototype.getEventTimeline = function(timelineSet, eventId) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let params = undefined;
|
||||||
|
if (this._clientOpts.lazyLoadMembers) {
|
||||||
|
params = {filter: JSON.stringify(LAZY_LOADING_MESSAGES_FILTER)};
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: we should implement a backoff (as per scrollback()) to deal more
|
// TODO: we should implement a backoff (as per scrollback()) to deal more
|
||||||
// nicely with HTTP errors.
|
// nicely with HTTP errors.
|
||||||
const self = this;
|
const self = this;
|
||||||
const promise =
|
const promise =
|
||||||
self._http.authedRequest(undefined, "GET", path,
|
self._http.authedRequest(undefined, "GET", path, params,
|
||||||
).then(function(res) {
|
).then(function(res) {
|
||||||
if (!res.event) {
|
if (!res.event) {
|
||||||
throw new Error("'event' not in '/context' result - homeserver too old?");
|
throw new Error("'event' not in '/context' result - homeserver too old?");
|
||||||
@@ -2098,6 +2103,8 @@ MatrixClient.prototype.getEventTimeline = function(timelineSet, eventId) {
|
|||||||
timeline.initialiseState(utils.map(res.state,
|
timeline.initialiseState(utils.map(res.state,
|
||||||
self.getEventMapper()));
|
self.getEventMapper()));
|
||||||
timeline.getState(EventTimeline.FORWARDS).paginationToken = res.end;
|
timeline.getState(EventTimeline.FORWARDS).paginationToken = res.end;
|
||||||
|
} else {
|
||||||
|
timeline.getState(EventTimeline.BACKWARDS).setUnknownStateEvents(res.state);
|
||||||
}
|
}
|
||||||
timelineSet.addEventsToTimeline(matrixEvents, true, timeline, res.start);
|
timelineSet.addEventsToTimeline(matrixEvents, true, timeline, res.start);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user