You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
change TimelineWindow to take a timelineSet rather than a Room
This commit is contained in:
@@ -1618,18 +1618,18 @@ MatrixClient.prototype.paginateEventContext = function(eventContext, opts) {
|
||||
/**
|
||||
* Get an EventTimeline for the given event
|
||||
*
|
||||
* <p>If the room object already has the given event in its store, the
|
||||
* <p>If the EventTimelineSet object already has the given event in its store, the
|
||||
* corresponding timeline will be returned. Otherwise, a /context request is
|
||||
* made, and used to construct an EventTimeline.
|
||||
*
|
||||
* @param {Room} room The room to look for the event in
|
||||
* @param {EventTimelineSet} timelineSet The timelineSet to look for the event in
|
||||
* @param {string} eventId The ID of the event to look for
|
||||
*
|
||||
* @return {module:client.Promise} Resolves:
|
||||
* {@link module:models/event-timeline~EventTimeline} including the given
|
||||
* event
|
||||
*/
|
||||
MatrixClient.prototype.getEventTimeline = function(room, eventId) {
|
||||
MatrixClient.prototype.getEventTimeline = function(timelineSet, eventId) {
|
||||
// don't allow any timeline support unless it's been enabled.
|
||||
if (!this.timelineSupport) {
|
||||
throw new Error("timeline support is disabled. Set the 'timelineSupport'" +
|
||||
@@ -1637,13 +1637,13 @@ MatrixClient.prototype.getEventTimeline = function(room, eventId) {
|
||||
" it.");
|
||||
}
|
||||
|
||||
if (room.getTimelineForEvent(eventId)) {
|
||||
return q(room.getTimelineForEvent(eventId));
|
||||
if (timelineSet.getTimelineForEvent(eventId)) {
|
||||
return q(timelineSet.getTimelineForEvent(eventId));
|
||||
}
|
||||
|
||||
var path = utils.encodeUri(
|
||||
"/rooms/$roomId/context/$eventId", {
|
||||
$roomId: room.roomId,
|
||||
$roomId: timelineSet.room.roomId,
|
||||
$eventId: eventId,
|
||||
}
|
||||
);
|
||||
@@ -1660,8 +1660,8 @@ MatrixClient.prototype.getEventTimeline = function(room, eventId) {
|
||||
|
||||
// by the time the request completes, the event might have ended up in
|
||||
// the timeline.
|
||||
if (room.getTimelineForEvent(eventId)) {
|
||||
return room.getTimelineForEvent(eventId);
|
||||
if (timelineSet.getTimelineForEvent(eventId)) {
|
||||
return timelineSet.getTimelineForEvent(eventId);
|
||||
}
|
||||
|
||||
// we start with the last event, since that's the point at which we
|
||||
@@ -1673,21 +1673,22 @@ MatrixClient.prototype.getEventTimeline = function(room, eventId) {
|
||||
.concat(res.events_before);
|
||||
var matrixEvents = utils.map(events, self.getEventMapper());
|
||||
|
||||
var timeline = room.getTimelineForEvent(matrixEvents[0].getId());
|
||||
var timeline = timelineSet.getTimelineForEvent(matrixEvents[0].getId());
|
||||
if (!timeline) {
|
||||
timeline = room.addTimeline();
|
||||
timeline = timelineSet.addTimeline();
|
||||
timeline.initialiseState(utils.map(res.state,
|
||||
self.getEventMapper()));
|
||||
timeline.getState(EventTimeline.FORWARDS).paginationToken = res.end;
|
||||
}
|
||||
room.addEventsToTimeline(matrixEvents, true, timeline, res.start);
|
||||
timelineSet.addEventsToTimeline(matrixEvents, true, timeline, res.start);
|
||||
|
||||
// there is no guarantee that the event ended up in "timeline" (we
|
||||
// might have switched to a neighbouring timeline) - so check the
|
||||
// room's index again. On the other hand, there's no guarantee the
|
||||
// event ended up anywhere, if it was later redacted, so we just
|
||||
// return the timeline we first thought of.
|
||||
return room.getTimelineForEvent(eventId) || timeline;
|
||||
var tl = timelineSet.getTimelineForEvent(eventId) || timeline;
|
||||
return tl;
|
||||
});
|
||||
return promise;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user