updated channel select function to clear any errors

This commit is contained in:
bill bittner 2018-01-24 15:29:23 -08:00
parent 6a8a908130
commit 6d37843c09
2 changed files with 4 additions and 2 deletions

View file

@ -1,5 +1,5 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {setPublishInChannel, updateSelectedChannel} from 'actions/publish'; import {setPublishInChannel, updateSelectedChannel, updateError} from 'actions/publish';
import View from './view.jsx'; import View from './view.jsx';
const mapStateToProps = ({ channel, publish }) => { const mapStateToProps = ({ channel, publish }) => {
@ -14,9 +14,11 @@ const mapStateToProps = ({ channel, publish }) => {
const mapDispatchToProps = dispatch => { const mapDispatchToProps = dispatch => {
return { return {
onPublishInChannelChange: (value) => { onPublishInChannelChange: (value) => {
dispatch(updateError('channel', null));
dispatch(setPublishInChannel(value)); dispatch(setPublishInChannel(value));
}, },
onChannelSelect: (value) => { onChannelSelect: (value) => {
dispatch(updateError('channel', null));
dispatch(updateSelectedChannel(value)); dispatch(updateSelectedChannel(value));
}, },
}; };

View file

@ -21,7 +21,7 @@ class PublishForm extends React.Component {
// if publishInChannel is true, is a channel selected & logged in? // if publishInChannel is true, is a channel selected & logged in?
if (this.props.publishInChannel && (this.props.selectedChannel !== this.props.loggedInChannel.name)) { if (this.props.publishInChannel && (this.props.selectedChannel !== this.props.loggedInChannel.name)) {
// update state with error // update state with error
this.props.onChannelSelectionError('Select "Anonymous" or log in to a channel'); this.props.onChannelSelectionError('Select a channel or Anonymous');
// reject this promise // reject this promise
return reject(new Error('Fix the channel')); return reject(new Error('Fix the channel'));
} }