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
only call setEventMetadata on unfiltered timelineSets
This commit is contained in:
@@ -234,23 +234,29 @@ EventTimeline.prototype.setNeighbouringTimeline = function(neighbour, direction)
|
|||||||
EventTimeline.prototype.addEvent = function(event, atStart) {
|
EventTimeline.prototype.addEvent = function(event, atStart) {
|
||||||
var stateContext = atStart ? this._startState : this._endState;
|
var stateContext = atStart ? this._startState : this._endState;
|
||||||
|
|
||||||
EventTimeline.setEventMetadata(event, stateContext, atStart);
|
// only call setEventMetadata on the unfiltered timelineSets
|
||||||
|
var timelineSet = this.getTimelineSet();
|
||||||
|
if (timelineSet.room &&
|
||||||
|
timelineSet.room.getUnfilteredTimelineSet() === timelineSet)
|
||||||
|
{
|
||||||
|
EventTimeline.setEventMetadata(event, stateContext, atStart);
|
||||||
|
|
||||||
// modify state
|
// modify state
|
||||||
if (event.isState()) {
|
if (event.isState()) {
|
||||||
stateContext.setStateEvents([event]);
|
stateContext.setStateEvents([event]);
|
||||||
// it is possible that the act of setting the state event means we
|
// it is possible that the act of setting the state event means we
|
||||||
// can set more metadata (specifically sender/target props), so try
|
// can set more metadata (specifically sender/target props), so try
|
||||||
// it again if the prop wasn't previously set. It may also mean that
|
// it again if the prop wasn't previously set. It may also mean that
|
||||||
// the sender/target is updated (if the event set was a room member event)
|
// the sender/target is updated (if the event set was a room member event)
|
||||||
// so we want to use the *updated* member (new avatar/name) instead.
|
// so we want to use the *updated* member (new avatar/name) instead.
|
||||||
//
|
//
|
||||||
// However, we do NOT want to do this on member events if we're going
|
// However, we do NOT want to do this on member events if we're going
|
||||||
// back in time, else we'll set the .sender value for BEFORE the given
|
// back in time, else we'll set the .sender value for BEFORE the given
|
||||||
// member event, whereas we want to set the .sender value for the ACTUAL
|
// member event, whereas we want to set the .sender value for the ACTUAL
|
||||||
// member event itself.
|
// member event itself.
|
||||||
if (!event.sender || (event.getType() === "m.room.member" && !atStart)) {
|
if (!event.sender || (event.getType() === "m.room.member" && !atStart)) {
|
||||||
EventTimeline.setEventMetadata(event, stateContext, atStart);
|
EventTimeline.setEventMetadata(event, stateContext, atStart);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user