Skip to content

Commit

Permalink
Merge pull request #617 from matrix-org/dbkr/fix_push_actions_frozen_…
Browse files Browse the repository at this point in the history
…matrixevents

Precompute push actions for state events
  • Loading branch information
ara4n authored Feb 23, 2018
2 parents f9cc5cb + 7165204 commit 9523846
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,17 @@ SyncApi.prototype._processRoomEvents = function(room, stateEventList,
const liveTimeline = room.getLiveTimeline();
const timelineWasEmpty = liveTimeline.getEvents().length == 0;
if (timelineWasEmpty) {
// Passing these events into initialiseState will freeze them, so we need
// to compute and cache the push actions for them now, otherwise sync dies
// with an attempt to assign to read only property.
// XXX: This is pretty horrible and is assuming all sorts of behaviour from
// these functions that it shouldn't be. We should probably either store the
// push actions cache elsewhere so we can freeze MatrixEvents, or otherwise
// find some solution where MatrixEvents are immutable but allow for a cache
// field.
for (const ev of stateEventList) {
this.client.getPushActionsForEvent(ev);
}
liveTimeline.initialiseState(stateEventList);
}

Expand Down

0 comments on commit 9523846

Please sign in to comment.