From 757bc9fe320e0966fca8934abb0896ab3c712f01 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 12 Sep 2017 14:47:26 +0100 Subject: [PATCH] Update roomlist when an event is decrypted Events are now decrypted asynchronously, so are not decrypted at the time of the Room.timeline which is when our RoomList got the chance to update. It needs to update once the event has been decrypted. Ideally we would not update the whole room list order, but this is how all the room list re-ordering happens right now, so staying consistent with this. Fixes https://github.com/vector-im/riot-web/issues/5020 --- src/components/views/rooms/RoomList.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index b7b2e5ecea..ff656ed793 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -87,6 +87,7 @@ module.exports = React.createClass({ cli.on("Room.receipt", this.onRoomReceipt); cli.on("RoomState.events", this.onRoomStateEvents); cli.on("RoomMember.name", this.onRoomMemberName); + cli.on("Event.decrypted", this.onEventDecrypted); cli.on("accountData", this.onAccountData); this.refreshRoomList(); @@ -154,6 +155,7 @@ module.exports = React.createClass({ MatrixClientPeg.get().removeListener("Room.receipt", this.onRoomReceipt); MatrixClientPeg.get().removeListener("RoomState.events", this.onRoomStateEvents); MatrixClientPeg.get().removeListener("RoomMember.name", this.onRoomMemberName); + MatrixClientPeg.get().removeListener("Event.decrypted", this.onEventDecrypted); MatrixClientPeg.get().removeListener("accountData", this.onAccountData); } // cancel any pending calls to the rate_limited_funcs @@ -223,6 +225,11 @@ module.exports = React.createClass({ this._delayedRefreshRoomList(); }, + onEventDecrypted: function(ev) { + // An event being decrypted may mean we need to re-order the room list + this._delayedRefreshRoomList(); + }, + onAccountData: function(ev) { if (ev.getType() == 'm.direct') { this._delayedRefreshRoomList();