Use ChangeDisplayName for implict display name saving on enter

pull/21833/head
Kegan Dougal 2015-12-23 14:14:25 +00:00
parent 1af5018597
commit e657b40a7e
2 changed files with 5 additions and 14 deletions

View File

@ -21,6 +21,7 @@ var dis = require("../../dispatcher");
var q = require('q'); var q = require('q');
var version = require('../../../package.json').version; var version = require('../../../package.json').version;
var UserSettingsStore = require('../../UserSettingsStore'); var UserSettingsStore = require('../../UserSettingsStore');
var ChangeDisplayName = require("../views/settings/ChangeDisplayName");
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'UserSettings', displayName: 'UserSettings',
@ -38,7 +39,6 @@ module.exports = React.createClass({
getInitialState: function() { getInitialState: function() {
return { return {
avatarUrl: null, avatarUrl: null,
displayName: null,
threePids: [], threePids: [],
clientVersion: version, clientVersion: version,
phase: "UserSettings.LOADING", // LOADING, DISPLAY, SAVING phase: "UserSettings.LOADING", // LOADING, DISPLAY, SAVING
@ -53,7 +53,6 @@ module.exports = React.createClass({
]).done(function(resps) { ]).done(function(resps) {
self.setState({ self.setState({
avatarUrl: resps[0].avatar_url, avatarUrl: resps[0].avatar_url,
displayName: resps[0].displayname,
threepids: resps[1].threepids, threepids: resps[1].threepids,
phase: "UserSettings.DISPLAY", phase: "UserSettings.DISPLAY",
}); });
@ -90,10 +89,6 @@ module.exports = React.createClass({
// savePromises.push( UserSettingsStore.saveAvatarUrl(this.state.avatarUrl) ); // savePromises.push( UserSettingsStore.saveAvatarUrl(this.state.avatarUrl) );
// } // }
if (this.state.originalState.displayName !== this.state.displayName) {
savePromises.push( UserSettingsStore.saveDisplayName(this.state.displayName) );
}
if (this.state.originalState.threepids.length !== this.state.threepids.length || if (this.state.originalState.threepids.length !== this.state.threepids.length ||
this.state.originalState.threepids.every((element, index) => { this.state.originalState.threepids.every((element, index) => {
return element === this.state.threepids[index]; return element === this.state.threepids[index];
@ -161,10 +156,6 @@ module.exports = React.createClass({
this.logoutModal.closeDialog(); this.logoutModal.closeDialog();
}, },
onDisplayNameChange: function(event) {
this.setState({ displayName: event.target.value });
},
onEnableNotificationsChange: function(event) { onEnableNotificationsChange: function(event) {
// don't bother waiting for Save to be clicked, as that'd be silly // don't bother waiting for Save to be clicked, as that'd be silly
UserSettingsStore.setEnableNotifications( this.refs.enableNotifications.value ); UserSettingsStore.setEnableNotifications( this.refs.enableNotifications.value );
@ -202,9 +193,7 @@ module.exports = React.createClass({
<label htmlFor="displayName">Display name</label> <label htmlFor="displayName">Display name</label>
</div> </div>
<div className="mx_UserSettings_profileInputCell"> <div className="mx_UserSettings_profileInputCell">
<input id="displayName" ref="displayName" <ChangeDisplayName />
value={ this.state.displayName }
onChange={ this.onDisplayNameChange } />
</div> </div>
</div> </div>

View File

@ -98,7 +98,9 @@ module.exports = React.createClass({
} else { } else {
var EditableText = sdk.getComponent('elements.EditableText'); var EditableText = sdk.getComponent('elements.EditableText');
return ( return (
<EditableText ref="displayname_edit" initialValue={this.state.displayName} label="Click to set display name." onValueChanged={this.onValueChanged}/> <EditableText ref="displayname_edit" initialValue={this.state.displayName}
label="Click to set display name."
onValueChanged={this.onValueChanged} />
); );
} }
} }