You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-01 04:43:29 +03:00
reemit Room.timeline events correctly
This commit is contained in:
@@ -163,6 +163,7 @@ function Room(roomId, opts) {
|
|||||||
// all our per-room timeline lists. the first one is the unfiltered ones;
|
// all our per-room timeline lists. the first one is the unfiltered ones;
|
||||||
// the subsequent ones are the filtered ones in no particular order.
|
// the subsequent ones are the filtered ones in no particular order.
|
||||||
this._timelineLists = [ new EventTimelineList(roomId, this, opts) ];
|
this._timelineLists = [ new EventTimelineList(roomId, this, opts) ];
|
||||||
|
reEmit(this, this._timelineLists[0], [ "Room.timeline" ]);
|
||||||
|
|
||||||
this._fixUpLegacyTimelineFields();
|
this._fixUpLegacyTimelineFields();
|
||||||
|
|
||||||
@@ -453,6 +454,7 @@ Room.prototype.addFilteredTimelineList = function(filter) {
|
|||||||
filter: filter,
|
filter: filter,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
reEmit(this, timelineList, [ "Room.timeline" ]);
|
||||||
this._filteredTimelineLists[filter.filterId] = timelineList;
|
this._filteredTimelineLists[filter.filterId] = timelineList;
|
||||||
this._timelineLists.push(timelineList);
|
this._timelineLists.push(timelineList);
|
||||||
};
|
};
|
||||||
@@ -1194,6 +1196,25 @@ function calculateRoomName(room, userId, ignoreRoomNameEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: copypasted from sync.js
|
||||||
|
function reEmit(reEmitEntity, emittableEntity, eventNames) {
|
||||||
|
utils.forEach(eventNames, function(eventName) {
|
||||||
|
// setup a listener on the entity (the Room, User, etc) for this event
|
||||||
|
emittableEntity.on(eventName, function() {
|
||||||
|
// take the args from the listener and reuse them, adding the
|
||||||
|
// event name to the arg list so it works with .emit()
|
||||||
|
// Transformation Example:
|
||||||
|
// listener on "foo" => function(a,b) { ... }
|
||||||
|
// Re-emit on "thing" => thing.emit("foo", a, b)
|
||||||
|
var newArgs = [eventName];
|
||||||
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
|
newArgs.push(arguments[i]);
|
||||||
|
}
|
||||||
|
reEmitEntity.emit.apply(reEmitEntity, newArgs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Room class.
|
* The Room class.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user