From 67824e9accffacc08e6209fc87f4dd99144f07f0 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 24 Aug 2017 11:35:01 +0100 Subject: [PATCH] Force update on timelinepanel when event decrypted Partially fixes https://github.com/vector-im/riot-web/issues/4865 (the part about messages not appearing in the timeline until you move the cursor over the window). Requires https://github.com/matrix-org/matrix-js-sdk/pull/529 --- src/components/structures/TimelinePanel.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 6be31361dd..2840fd4579 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -197,6 +197,7 @@ var TimelinePanel = React.createClass({ MatrixClientPeg.get().on("Room.receipt", this.onRoomReceipt); MatrixClientPeg.get().on("Room.localEchoUpdated", this.onLocalEchoUpdated); MatrixClientPeg.get().on("Room.accountData", this.onAccountData); + MatrixClientPeg.get().on("Event.decrypted", this.onEventDecrypted); MatrixClientPeg.get().on("sync", this.onSync); this._initTimeline(this.props); @@ -266,6 +267,7 @@ var TimelinePanel = React.createClass({ client.removeListener("Room.receipt", this.onRoomReceipt); client.removeListener("Room.localEchoUpdated", this.onLocalEchoUpdated); client.removeListener("Room.accountData", this.onAccountData); + client.removeListener("Event.decrypted", this.onEventDecrypted); client.removeListener("sync", this.onSync); } }, @@ -503,6 +505,16 @@ var TimelinePanel = React.createClass({ }, this.props.onReadMarkerUpdated); }, + onEventDecrypted: function(ev) { + // Need to update as we don't display event tiles for events that + // haven't yet been decrypted. The event will have just been updated + // in place so we just need to re-render. + // TODO: We should restrict this to only events in our timeline, + // but possibly the event tile itself should just update when this + // happens to save us re-rendering the whole timeline. + this.forceUpdate(); + }, + onSync: function(state, prevState, data) { this.setState({clientSyncState: state}); },