mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-18 14:44:58 +08:00
Fix SetDisplayNameDialog
SetDisplayNameDialog got broken by the changes to support asynchronous loading of dialogs. Rather than poking into its internals via a ref, make it return its result via onFinished. Fixes https://github.com/vector-im/riot-web/issues/3047
This commit is contained in:
parent
770820e6fa
commit
29b4dde878
@ -722,15 +722,11 @@ module.exports = React.createClass({
|
|||||||
if (!result.displayname) {
|
if (!result.displayname) {
|
||||||
var SetDisplayNameDialog = sdk.getComponent('views.dialogs.SetDisplayNameDialog');
|
var SetDisplayNameDialog = sdk.getComponent('views.dialogs.SetDisplayNameDialog');
|
||||||
var dialog_defer = q.defer();
|
var dialog_defer = q.defer();
|
||||||
var dialog_ref;
|
|
||||||
Modal.createDialog(SetDisplayNameDialog, {
|
Modal.createDialog(SetDisplayNameDialog, {
|
||||||
currentDisplayName: result.displayname,
|
currentDisplayName: result.displayname,
|
||||||
ref: (r) => {
|
onFinished: (submitted, newDisplayName) => {
|
||||||
dialog_ref = r;
|
|
||||||
},
|
|
||||||
onFinished: (submitted) => {
|
|
||||||
if (submitted) {
|
if (submitted) {
|
||||||
cli.setDisplayName(dialog_ref.getValue()).done(() => {
|
cli.setDisplayName(newDisplayName).done(() => {
|
||||||
dialog_defer.resolve();
|
dialog_defer.resolve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,12 @@ var React = require("react");
|
|||||||
var sdk = require("../../../index.js");
|
var sdk = require("../../../index.js");
|
||||||
var MatrixClientPeg = require("../../../MatrixClientPeg");
|
var MatrixClientPeg = require("../../../MatrixClientPeg");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prompt the user to set a display name.
|
||||||
|
*
|
||||||
|
* On success, `onFinished(true, newDisplayName)` is called.
|
||||||
|
*/
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'SetDisplayNameDialog',
|
displayName: 'SetDisplayNameDialog',
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -42,10 +48,6 @@ module.exports = React.createClass({
|
|||||||
this.refs.input_value.select();
|
this.refs.input_value.select();
|
||||||
},
|
},
|
||||||
|
|
||||||
getValue: function() {
|
|
||||||
return this.state.value;
|
|
||||||
},
|
|
||||||
|
|
||||||
onValueChange: function(ev) {
|
onValueChange: function(ev) {
|
||||||
this.setState({
|
this.setState({
|
||||||
value: ev.target.value
|
value: ev.target.value
|
||||||
@ -54,7 +56,7 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
onFormSubmit: function(ev) {
|
onFormSubmit: function(ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
this.props.onFinished(true);
|
this.props.onFinished(true, this.state.value);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user