From deca90d0a70e14a54a44f2d840b05fb972bc86fa Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 21 Jan 2016 00:16:10 +0000 Subject: [PATCH] fix up Start Chat behaviour as per Amandine's feedback --- src/components/structures/MatrixChat.js | 2 +- src/components/structures/RoomView.js | 9 +++++++++ src/components/views/rooms/RoomHeader.js | 14 ++++++++++++-- src/components/views/rooms/RoomSettings.js | 8 -------- src/components/views/rooms/SearchableEntityList.js | 2 +- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 71910b6f31..f533c60a99 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -375,7 +375,7 @@ module.exports = React.createClass({ dis.dispatch({ action: 'view_room', room_id: res.room_id, - show_settings: true, + // show_settings: true, }); }, function(err) { modal.close(); diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index ae825eac24..cb4bde3d6f 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -457,6 +457,15 @@ module.exports = React.createClass({ } this._updateTabCompleteList(this.state.room); + + // XXX: EVIL HACK to autofocus inviting on empty rooms. + // We use the setTimeout to avoid racing with focus_composer. + if (this.state.room && this.state.room.getJoinedMembers().length == 1) { + var inviteBox = document.getElementById("mx_SearchableEntityList_query"); + setTimeout(function() { + inviteBox.focus(); + }, 50); + } }, _updateTabCompleteList: function(room) { diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index 5340798875..6fab2a9989 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -190,7 +190,7 @@ module.exports = React.createClass({ var can_set_room_topic = current_user_level >= room_topic_level; var placeholderName = "Unnamed Room"; - if (this.state.defaultName && this.state.defaultName !== '?') { + if (this.state.defaultName && this.state.defaultName !== 'Empty room') { placeholderName += " (" + this.state.defaultName + ")"; } @@ -218,9 +218,19 @@ module.exports = React.createClass({ searchStatus =
 (~{ this.props.searchInfo.searchCount } results)
; } + // XXX: this is a bit inefficient - we could just compare room.name for 'Empty room'... + var members = this.props.room.getJoinedMembers(); + var settingsHint = false; + if (members.length === 1 && members[0].userId === MatrixClientPeg.get().credentials.userId) { + var name = this.props.room.currentState.getStateEvents('m.room.name', ''); + if (!name || !name.getContent().name) { + settingsHint = true; + } + } + name =
-
{ this.props.room.name }
+
{ this.props.room.name }
{ searchStatus }
diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index a978eb87f3..53dedbe812 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -43,14 +43,6 @@ module.exports = React.createClass({ onCancelClick: React.PropTypes.func, }, - componentDidMount: function() { - // XXX: dirty hack to gutwrench to focus on the invite box - if (this.props.room.getJoinedMembers().length == 1) { - var inviteBox = document.getElementById("mx_MemberList_invite"); - if (inviteBox) setTimeout(function() { inviteBox.focus(); }, 0); - } - }, - getInitialState: function() { // work out the initial color index var room_color_index = undefined; diff --git a/src/components/views/rooms/SearchableEntityList.js b/src/components/views/rooms/SearchableEntityList.js index 506a8ba92d..05267f5e6b 100644 --- a/src/components/views/rooms/SearchableEntityList.js +++ b/src/components/views/rooms/SearchableEntityList.js @@ -96,7 +96,7 @@ var SearchableEntityList = React.createClass({ if (this.props.showInputBox) { inputBox = (
-