Clear state info on section change

Этот коммит содержится в:
nickago
2015-08-18 13:38:52 -07:00
родитель baebfdcf9f
Коммит 3cc24b1d2a
2 изменённых файлов: 13 добавлений и 9 удалений

Просмотреть файл

@@ -163,7 +163,7 @@ module.exports = React.createClass({
} }
}, },
updateSection: function(section) { updateSection: function(section) {
this.setState({clientError: ''}); this.setState(assign({}, this.getInitialState(), {clientError: ''}));
this.submitActive = false; this.submitActive = false;
this.props.updateSection(section); this.props.updateSection(section);
}, },

Просмотреть файл

@@ -100,6 +100,10 @@ module.exports = React.createClass({
this.props.updateTab('general'); this.props.updateTab('general');
}, },
updateSection: function(section) {
this.setState(this.getInitialState());
this.props.updateSection(section);
},
componentDidMount: function() { componentDidMount: function() {
UserStore.addChangeListener(this._onChange); UserStore.addChangeListener(this._onChange);
$('#user_settings').on('hidden.bs.modal', this.handleClose); $('#user_settings').on('hidden.bs.modal', this.handleClose);
@@ -209,7 +213,7 @@ module.exports = React.createClass({
inputs={inputs} inputs={inputs}
submit={this.handleSubmit} submit={this.handleSubmit}
server_error={server_error} server_error={server_error}
updateSection={function(e){self.props.updateSection("");e.preventDefault();}} updateSection={function(e){self.updateSection("");e.preventDefault();}}
/> />
); );
} else { } else {
@@ -226,7 +230,7 @@ module.exports = React.createClass({
<SettingItemMin <SettingItemMin
title="Send desktop notifications" title="Send desktop notifications"
describe={describe} describe={describe}
updateSection={function(){self.props.updateSection("desktop");}} updateSection={function(){self.updateSection("desktop");}}
/> />
); );
} }
@@ -257,7 +261,7 @@ module.exports = React.createClass({
inputs={inputs} inputs={inputs}
submit={this.handleSubmit} submit={this.handleSubmit}
server_error={server_error} server_error={server_error}
updateSection={function(e){self.props.updateSection("");e.preventDefault();}} updateSection={function(e){self.updateSection("");e.preventDefault();}}
/> />
); );
} else { } else {
@@ -274,7 +278,7 @@ module.exports = React.createClass({
<SettingItemMin <SettingItemMin
title="Desktop notification sounds" title="Desktop notification sounds"
describe={describe} describe={describe}
updateSection={function(){self.props.updateSection("sound");}} updateSection={function(){self.updateSection("sound");}}
disableOpen = {!this.state.soundNeeded} disableOpen = {!this.state.soundNeeded}
/> />
); );
@@ -307,7 +311,7 @@ module.exports = React.createClass({
inputs={inputs} inputs={inputs}
submit={this.handleSubmit} submit={this.handleSubmit}
server_error={server_error} server_error={server_error}
updateSection={function(e){self.props.updateSection("");e.preventDefault();}} updateSection={function(e){self.updateSection("");e.preventDefault();}}
/> />
); );
} else { } else {
@@ -322,7 +326,7 @@ module.exports = React.createClass({
<SettingItemMin <SettingItemMin
title="Email notifications" title="Email notifications"
describe={describe} describe={describe}
updateSection={function(){self.props.updateSection("email");}} updateSection={function(){self.updateSection("email");}}
/> />
); );
} }
@@ -400,7 +404,7 @@ module.exports = React.createClass({
inputs={inputs} inputs={inputs}
submit={this.handleSubmit} submit={this.handleSubmit}
server_error={server_error} server_error={server_error}
updateSection={function(e){self.props.updateSection("");e.preventDefault();}} updateSection={function(e){self.updateSection("");e.preventDefault();}}
/> />
); );
} else { } else {
@@ -427,7 +431,7 @@ module.exports = React.createClass({
<SettingItemMin <SettingItemMin
title="Words that trigger mentions" title="Words that trigger mentions"
describe={describe} describe={describe}
updateSection={function(){self.props.updateSection("keys");}} updateSection={function(){self.updateSection("keys");}}
/> />
); );
} }