From 500c12b1f2ec7d529cf7b941145f178a0237c834 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 5 Feb 2016 14:32:30 +0000 Subject: [PATCH 1/2] Fix tab complete rate limited functions can't have arguments, so don't pass the room into _updateTabCompleteList as it's always the room in our state. --- src/components/structures/RoomView.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 425852f07f..70294ed92d 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -523,7 +523,7 @@ module.exports = React.createClass({ onRoomStateMember: function(ev, state, member) { if (member.roomId === this.props.roomId) { // a member state changed in this room, refresh the tab complete list - this._updateTabCompleteList(this.state.room); + this._updateTabCompleteList(); var room = MatrixClientPeg.get().getRoom(this.props.roomId); if (!room) return; @@ -606,7 +606,7 @@ module.exports = React.createClass({ roomView.addEventListener('dragend', this.onDragLeaveOrEnd); } - this._updateTabCompleteList(this.state.room); + this._updateTabCompleteList(); // XXX: EVIL HACK to autofocus inviting on empty rooms. // We use the setTimeout to avoid racing with focus_composer. @@ -620,12 +620,12 @@ module.exports = React.createClass({ } }, - _updateTabCompleteList: new rate_limited_func(function(room) { - if (!room || !this.tabComplete) { + _updateTabCompleteList: new rate_limited_func(function() { + if (!this.state.room || !this.tabComplete) { return; } this.tabComplete.setCompletionList( - MemberEntry.fromMemberList(room.getJoinedMembers()).concat( + MemberEntry.fromMemberList(this.state.room.getJoinedMembers()).concat( CommandEntry.fromCommands(SlashCommands.getCommandList()) ) ); From 7ccce1dc91f910e9797ed15b3289e934e485f9ea Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 5 Feb 2016 16:58:37 +0000 Subject: [PATCH 2/2] Reset truncation when the text box is cleared --- src/components/views/rooms/SearchableEntityList.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/views/rooms/SearchableEntityList.js b/src/components/views/rooms/SearchableEntityList.js index acd20f3984..c91e058e4c 100644 --- a/src/components/views/rooms/SearchableEntityList.js +++ b/src/components/views/rooms/SearchableEntityList.js @@ -81,6 +81,8 @@ var SearchableEntityList = React.createClass({ var q = ev.target.value; this.setState({ query: q, + // reset truncation if they back out the entire text + truncateAt: (q.length === 0 ? this.props.truncateAt : this.state.truncateAt), results: this.getSearchResults(q, this.props.entities) }, () => { // invoke the callback AFTER we've flushed the new state. We need to