mirror of https://github.com/vector-im/riot-web
Use ChangeDisplayName for implict display name saving on enter
parent
1af5018597
commit
e657b40a7e
|
@ -21,6 +21,7 @@ var dis = require("../../dispatcher");
|
|||
var q = require('q');
|
||||
var version = require('../../../package.json').version;
|
||||
var UserSettingsStore = require('../../UserSettingsStore');
|
||||
var ChangeDisplayName = require("../views/settings/ChangeDisplayName");
|
||||
|
||||
module.exports = React.createClass({
|
||||
displayName: 'UserSettings',
|
||||
|
@ -38,7 +39,6 @@ module.exports = React.createClass({
|
|||
getInitialState: function() {
|
||||
return {
|
||||
avatarUrl: null,
|
||||
displayName: null,
|
||||
threePids: [],
|
||||
clientVersion: version,
|
||||
phase: "UserSettings.LOADING", // LOADING, DISPLAY, SAVING
|
||||
|
@ -53,7 +53,6 @@ module.exports = React.createClass({
|
|||
]).done(function(resps) {
|
||||
self.setState({
|
||||
avatarUrl: resps[0].avatar_url,
|
||||
displayName: resps[0].displayname,
|
||||
threepids: resps[1].threepids,
|
||||
phase: "UserSettings.DISPLAY",
|
||||
});
|
||||
|
@ -90,10 +89,6 @@ module.exports = React.createClass({
|
|||
// 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 ||
|
||||
this.state.originalState.threepids.every((element, index) => {
|
||||
return element === this.state.threepids[index];
|
||||
|
@ -161,10 +156,6 @@ module.exports = React.createClass({
|
|||
this.logoutModal.closeDialog();
|
||||
},
|
||||
|
||||
onDisplayNameChange: function(event) {
|
||||
this.setState({ displayName: event.target.value });
|
||||
},
|
||||
|
||||
onEnableNotificationsChange: function(event) {
|
||||
// don't bother waiting for Save to be clicked, as that'd be silly
|
||||
UserSettingsStore.setEnableNotifications( this.refs.enableNotifications.value );
|
||||
|
@ -202,9 +193,7 @@ module.exports = React.createClass({
|
|||
<label htmlFor="displayName">Display name</label>
|
||||
</div>
|
||||
<div className="mx_UserSettings_profileInputCell">
|
||||
<input id="displayName" ref="displayName"
|
||||
value={ this.state.displayName }
|
||||
onChange={ this.onDisplayNameChange } />
|
||||
<ChangeDisplayName />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -98,7 +98,9 @@ module.exports = React.createClass({
|
|||
} else {
|
||||
var EditableText = sdk.getComponent('elements.EditableText');
|
||||
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} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue