Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e567162

Browse files
authored
Merge pull request #648 from matrix-org/rav/fix_set_displayname
Fix SetDisplayNameDialog
2 parents f66e412 + 29b4dde commit e567162

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/components/structures/RoomView.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -722,15 +722,11 @@ module.exports = React.createClass({
722722
if (!result.displayname) {
723723
var SetDisplayNameDialog = sdk.getComponent('views.dialogs.SetDisplayNameDialog');
724724
var dialog_defer = q.defer();
725-
var dialog_ref;
726725
Modal.createDialog(SetDisplayNameDialog, {
727726
currentDisplayName: result.displayname,
728-
ref: (r) => {
729-
dialog_ref = r;
730-
},
731-
onFinished: (submitted) => {
727+
onFinished: (submitted, newDisplayName) => {
732728
if (submitted) {
733-
cli.setDisplayName(dialog_ref.getValue()).done(() => {
729+
cli.setDisplayName(newDisplayName).done(() => {
734730
dialog_defer.resolve();
735731
});
736732
}

src/components/views/dialogs/SetDisplayNameDialog.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ var React = require("react");
1818
var sdk = require("../../../index.js");
1919
var MatrixClientPeg = require("../../../MatrixClientPeg");
2020

21+
22+
/**
23+
* Prompt the user to set a display name.
24+
*
25+
* On success, `onFinished(true, newDisplayName)` is called.
26+
*/
2127
module.exports = React.createClass({
2228
displayName: 'SetDisplayNameDialog',
2329
propTypes: {
@@ -42,10 +48,6 @@ module.exports = React.createClass({
4248
this.refs.input_value.select();
4349
},
4450

45-
getValue: function() {
46-
return this.state.value;
47-
},
48-
4951
onValueChange: function(ev) {
5052
this.setState({
5153
value: ev.target.value
@@ -54,7 +56,7 @@ module.exports = React.createClass({
5456

5557
onFormSubmit: function(ev) {
5658
ev.preventDefault();
57-
this.props.onFinished(true);
59+
this.props.onFinished(true, this.state.value);
5860
return false;
5961
},
6062

0 commit comments

Comments
 (0)