From 167da10b8bf4ae1366c519c01625aa262d7cb92f Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 4 Feb 2016 15:07:30 +0000 Subject: [PATCH] address PR comments --- src/components/structures/RoomView.js | 14 ++++---------- .../views/dialogs/SetDisplayNameDialog.js | 6 +----- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 644927e3bd..836ea1ea2f 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -700,15 +700,14 @@ module.exports = React.createClass({ var self = this; var cli = MatrixClientPeg.get(); - var join_defer; - var join_promise; + var display_name_promise = q(); // if this is the first room we're joining, check the user has a display name // and if they don't, prompt them to set one. // NB. This unfortunately does not re-use the ChangeDisplayName component because // it doesn't behave quite as desired here (we want an input field here rather than // content-editable, and we want a default). if (MatrixClientPeg.get().getRooms().length == 0) { - join_promise = cli.getProfileInfo(cli.credentials.userId).then((result) => { + display_name_promise = cli.getProfileInfo(cli.credentials.userId).then((result) => { if (!result.displayname) { var SetDisplayNameDialog = sdk.getComponent('views.dialogs.SetDisplayNameDialog'); var dialog_defer = q.defer(); @@ -717,8 +716,7 @@ module.exports = React.createClass({ var dialog_instance = { dialog_ref = r; }} onFinished={() => { - var new_displayname = dialog_ref.getValue() || dialog_ref.getDefaultValue(); - cli.setDisplayName(new_displayname).done(() => { + cli.setDisplayName(dialog_ref.getValue()).done(() => { dialog_defer.resolve(); }); modal.close(); @@ -727,13 +725,9 @@ module.exports = React.createClass({ return dialog_defer.promise; } }); - } else { - join_defer = q.defer(); - join_promise = join_defer.promise; - join_defer.resolve(); } - join_promise.then(() => { + display_name_promise.then(() => { return MatrixClientPeg.get().joinRoom(this.props.roomId) }).done(function() { // It is possible that there is no Room yet if state hasn't come down diff --git a/src/components/views/dialogs/SetDisplayNameDialog.js b/src/components/views/dialogs/SetDisplayNameDialog.js index 43d5908327..d1287e2570 100644 --- a/src/components/views/dialogs/SetDisplayNameDialog.js +++ b/src/components/views/dialogs/SetDisplayNameDialog.js @@ -27,14 +27,10 @@ module.exports = React.createClass({ getInitialState: function() { return { - value: this.props.currentDisplayName || this.getDefaultDisplayName(), + value: this.props.currentDisplayName || "Guest "+MatrixClientPeg.get().getUserIdLocalpart(), } }, - getDefaultDisplayName: function() { - return "Guest "+MatrixClientPeg.get().getUserIdLocalpart(); - }, - getValue: function() { return this.state.value; },