Merge pull request #136 from matrix-org/dbkr/prompt_display_name_on_join
Prompt for display name before joining your first room
This commit is contained in:
commit
d1467d2319
3 changed files with 106 additions and 1 deletions
|
@ -706,7 +706,38 @@ module.exports = React.createClass({
|
|||
|
||||
onJoinButtonClicked: function(ev) {
|
||||
var self = this;
|
||||
MatrixClientPeg.get().joinRoom(this.props.roomId).done(function() {
|
||||
|
||||
var cli = MatrixClientPeg.get();
|
||||
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) {
|
||||
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();
|
||||
var dialog_ref;
|
||||
var modal;
|
||||
var dialog_instance = <SetDisplayNameDialog currentDisplayName={result.displayname} ref={(r) => {
|
||||
dialog_ref = r;
|
||||
}} onFinished={() => {
|
||||
cli.setDisplayName(dialog_ref.getValue()).done(() => {
|
||||
dialog_defer.resolve();
|
||||
});
|
||||
modal.close();
|
||||
}} />
|
||||
modal = Modal.createDialogWithElement(dialog_instance);
|
||||
return dialog_defer.promise;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
// from /sync - joinRoom will resolve when the HTTP request to join succeeds,
|
||||
// NOT when it comes down /sync. If there is no room, we'll keep the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue