Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 814e08d

Browse files
authored
Merge pull request #1334 from matrix-org/dbkr/update_on_event_decrypted
Force update on timelinepanel when event decrypted
2 parents 3e92380 + a2943ac commit 814e08d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/components/structures/TimelinePanel.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ var TimelinePanel = React.createClass({
197197
MatrixClientPeg.get().on("Room.receipt", this.onRoomReceipt);
198198
MatrixClientPeg.get().on("Room.localEchoUpdated", this.onLocalEchoUpdated);
199199
MatrixClientPeg.get().on("Room.accountData", this.onAccountData);
200+
MatrixClientPeg.get().on("Event.decrypted", this.onEventDecrypted);
200201
MatrixClientPeg.get().on("sync", this.onSync);
201202

202203
this._initTimeline(this.props);
@@ -266,6 +267,7 @@ var TimelinePanel = React.createClass({
266267
client.removeListener("Room.receipt", this.onRoomReceipt);
267268
client.removeListener("Room.localEchoUpdated", this.onLocalEchoUpdated);
268269
client.removeListener("Room.accountData", this.onAccountData);
270+
client.removeListener("Event.decrypted", this.onEventDecrypted);
269271
client.removeListener("sync", this.onSync);
270272
}
271273
},
@@ -503,6 +505,18 @@ var TimelinePanel = React.createClass({
503505
}, this.props.onReadMarkerUpdated);
504506
},
505507

508+
onEventDecrypted: function(ev) {
509+
// Need to update as we don't display event tiles for events that
510+
// haven't yet been decrypted. The event will have just been updated
511+
// in place so we just need to re-render.
512+
// TODO: We should restrict this to only events in our timeline,
513+
// but possibly the event tile itself should just update when this
514+
// happens to save us re-rendering the whole timeline.
515+
if (ev.getRoomId() === this.props.timelineSet.room.roomId) {
516+
this.forceUpdate();
517+
}
518+
},
519+
506520
onSync: function(state, prevState, data) {
507521
this.setState({clientSyncState: state});
508522
},

0 commit comments

Comments
 (0)