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
prepend state from /messages to appropriate timeline/room state (excluding event context for now)
This commit is contained in:
@@ -2000,6 +2000,10 @@ MatrixClient.prototype.scrollback = function(room, limit, callback) {
|
|||||||
'b');
|
'b');
|
||||||
}).done(function(res) {
|
}).done(function(res) {
|
||||||
const matrixEvents = utils.map(res.chunk, _PojoToMatrixEventMapper(self));
|
const matrixEvents = utils.map(res.chunk, _PojoToMatrixEventMapper(self));
|
||||||
|
if (res.state) {
|
||||||
|
const stateEvents = utils.map(res.state, _PojoToMatrixEventMapper(self));
|
||||||
|
room.currentState.prependStateEvents(stateEvents);
|
||||||
|
}
|
||||||
room.addEventsToTimeline(matrixEvents, true, room.getLiveTimeline());
|
room.addEventsToTimeline(matrixEvents, true, room.getLiveTimeline());
|
||||||
room.oldState.paginationToken = res.end;
|
room.oldState.paginationToken = res.end;
|
||||||
if (res.chunk.length === 0) {
|
if (res.chunk.length === 0) {
|
||||||
@@ -2068,6 +2072,7 @@ MatrixClient.prototype.paginateEventContext = function(eventContext, opts) {
|
|||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
promise.then(function(res) {
|
promise.then(function(res) {
|
||||||
|
// TODO: no RoomState on EventContext, where should the members go?
|
||||||
let token = res.end;
|
let token = res.end;
|
||||||
if (res.chunk.length === 0) {
|
if (res.chunk.length === 0) {
|
||||||
token = null;
|
token = null;
|
||||||
@@ -2298,6 +2303,11 @@ MatrixClient.prototype.paginateEventTimeline = function(eventTimeline, opts) {
|
|||||||
dir,
|
dir,
|
||||||
eventTimeline.getFilter());
|
eventTimeline.getFilter());
|
||||||
promise.then(function(res) {
|
promise.then(function(res) {
|
||||||
|
if (res.state) {
|
||||||
|
const roomState = eventTimeline.getState(dir);
|
||||||
|
const stateEvents = utils.map(res.state, self.getEventMapper());
|
||||||
|
roomState.prependStateEvents(stateEvents);
|
||||||
|
}
|
||||||
const token = res.end;
|
const token = res.end;
|
||||||
const matrixEvents = utils.map(res.chunk, self.getEventMapper());
|
const matrixEvents = utils.map(res.chunk, self.getEventMapper());
|
||||||
eventTimeline.getTimelineSet()
|
eventTimeline.getTimelineSet()
|
||||||
|
|||||||
@@ -262,6 +262,15 @@ RoomState.prototype.clone = function() {
|
|||||||
return copy;
|
return copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
|||||||
Reference in New Issue
Block a user