You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-04 05:02:41 +03:00
Allow relations into the pending event list
Relations actually should go into the pending event list, just like messages. This is the easiest way to keep them in a holding area in case of unverified devices, etc. We still want the relations to local echo immediately, so we directly trigger the aggregation on the timeline sets.
This commit is contained in:
@@ -540,7 +540,7 @@ EventTimelineSet.prototype.addEventToTimeline = function(event, timeline,
|
||||
timeline.addEvent(event, toStartOfTimeline);
|
||||
this._eventIdToTimeline[eventId] = timeline;
|
||||
|
||||
this._aggregateRelations(event);
|
||||
this.aggregateRelations(event);
|
||||
|
||||
const data = {
|
||||
timeline: timeline,
|
||||
@@ -714,7 +714,7 @@ EventTimelineSet.prototype.getRelationsForEvent = function(
|
||||
* @param {MatrixEvent} event
|
||||
* The new relation event to be aggregated.
|
||||
*/
|
||||
EventTimelineSet.prototype._aggregateRelations = function(event) {
|
||||
EventTimelineSet.prototype.aggregateRelations = function(event) {
|
||||
if (!this._unstableClientRelationAggregation) {
|
||||
return;
|
||||
}
|
||||
@@ -722,7 +722,7 @@ EventTimelineSet.prototype._aggregateRelations = function(event) {
|
||||
// If the event is currently encrypted, wait until it has been decrypted.
|
||||
if (event.isBeingDecrypted()) {
|
||||
event.once("Event.decrypted", () => {
|
||||
this._aggregateRelations(event);
|
||||
this.aggregateRelations(event);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1127,16 +1127,28 @@ Room.prototype.addPendingEvent = function(event, txnId) {
|
||||
|
||||
this._txnToEvent[txnId] = event;
|
||||
|
||||
// TODO: We currently ignore `pendingEventOrdering` for relation events.
|
||||
// They are aggregated by the timeline set, and we want that to happen right
|
||||
// away for easy local echo, but it complicates what should be a general
|
||||
// code path by branching on the event type.
|
||||
if (!event.isRelation() && this._opts.pendingEventOrdering == "detached") {
|
||||
if (this._opts.pendingEventOrdering == "detached") {
|
||||
if (this._pendingEventList.some((e) => e.status === EventStatus.NOT_SENT)) {
|
||||
console.warn("Setting event as NOT_SENT due to messages in the same state");
|
||||
event.status = EventStatus.NOT_SENT;
|
||||
}
|
||||
this._pendingEventList.push(event);
|
||||
|
||||
// For pending events, add them to the relations collection immediately.
|
||||
// (The alternate case below already covers this as part of adding to
|
||||
// the timeline set.)
|
||||
// TODO: We should consider whether this means it would be a better
|
||||
// design to lift the relations handling up to the room instead.
|
||||
for (let i = 0; i < this._timelineSets.length; i++) {
|
||||
const timelineSet = this._timelineSets[i];
|
||||
if (timelineSet.getFilter()) {
|
||||
if (this._filter.filterRoomTimeline([event]).length) {
|
||||
timelineSet.aggregateRelations(event);
|
||||
}
|
||||
} else {
|
||||
timelineSet.aggregateRelations(event);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < this._timelineSets.length; i++) {
|
||||
const timelineSet = this._timelineSets[i];
|
||||
|
||||
Reference in New Issue
Block a user