Skip to content

Commit

Permalink
Add Event.relationsCreated event to listen for future relations col…
Browse files Browse the repository at this point in the history
…lections

If you ask for relations but none currently exist, we return `null` to avoid the
overhead of many empty relations objects in memory. However, we still want some
way to alert consumers when one _is_ later made, so this event level event
provides that.

Part of element-hq/element-web#9572
Part of element-hq/element-web#9485
  • Loading branch information
jryans committed May 13, 2019
1 parent 53d8cf0 commit 7ea820f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/models/event-timeline-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,10 @@ EventTimelineSet.prototype._aggregateRelations = function(event) {
eventType,
this.room,
);
const relatesToEvent = this.findEventById(relatesToEventId);
if (relatesToEvent) {
relatesToEvent.emit("Event.relationsCreated", relationType, eventType);
}
}

relationsWithEventType.addEvent(event);
Expand Down

0 comments on commit 7ea820f

Please sign in to comment.