From e18924c8fcd8fdf908aab9aa0b980d6136ec5c17 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 11 Jul 2017 10:42:02 +0100 Subject: [PATCH] Fix bug where a received message would remove completions for users `Array.prototype.splice` will return the array of removed items, not a new array. The array operated on is actually modified in-place. This was causing a few weird things to happen: https://github.com/vector-im/riot-web/issues/4511 and https://github.com/vector-im/riot-web/issues/4533. This should fix both of them but it is concerning that doing the tab completion is required to reproduce. Let's just see how this goes before closing the issues. Thanks @turt2live for reproducing both bugs, giving enough information for a fix :) --- src/autocomplete/UserProvider.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/autocomplete/UserProvider.js b/src/autocomplete/UserProvider.js index 0025a3c5e9..f052716b4b 100644 --- a/src/autocomplete/UserProvider.js +++ b/src/autocomplete/UserProvider.js @@ -101,7 +101,8 @@ export default class UserProvider extends AutocompleteProvider { onUserSpoke(user: RoomMember) { if(user.userId === MatrixClientPeg.get().credentials.userId) return; - this.users = this.users.splice( + // Move the user that spoke to the front of the array + this.users.splice( this.users.findIndex((user2) => user2.userId === user.userId), 1); this.users = [user, ...this.users];