@@ -36,7 +37,6 @@ class ChannelSelect extends React.Component {
{ this.props.publishInChannel && (
-
{this.props.channelError}
diff --git a/react/containers/PublishForm/index.js b/react/containers/PublishForm/index.js
index e83ae9e1..df1614b6 100644
--- a/react/containers/PublishForm/index.js
+++ b/react/containers/PublishForm/index.js
@@ -14,6 +14,7 @@ const mapStateToProps = ({ channel, publish }) => {
license : publish.metadata.license,
nsfw : publish.metadata.nsfw,
publishInChannel : publish.publishInChannel,
+ selectedChannel : publish.selectedChannel,
fileError : publish.error.file,
urlError : publish.error.url,
publishSubmitError: publish.error.publishSubmit,
@@ -34,6 +35,9 @@ const mapDispatchToProps = dispatch => {
onPublishStatusChange: (status, message) => {
dispatch(updatePublishStatus(status, message));
},
+ onChannelSelectionError: (value) => {
+ dispatch(updateError('channel', value));
+ },
onPublishSubmitError: (value) => {
dispatch(updateError('publishSubmit', value));
},
diff --git a/react/containers/PublishForm/view.jsx b/react/containers/PublishForm/view.jsx
index 56bf769b..5e596240 100644
--- a/react/containers/PublishForm/view.jsx
+++ b/react/containers/PublishForm/view.jsx
@@ -10,11 +10,24 @@ import * as publishStates from 'constants/publish_claim_states';
class PublishForm extends React.Component {
constructor (props) {
super(props);
- this.validatePublishRequest = this.validatePublishRequest.bind(this);
+ this.validateChannelSelection = this.validateChannelSelection.bind(this);
+ this.validatePublishParams = this.validatePublishParams.bind(this);
this.makePublishRequest = this.makePublishRequest.bind(this);
this.publish = this.publish.bind(this);
}
- validatePublishRequest () {
+ validateChannelSelection () {
+ // make sure all required data is provided
+ return new Promise((resolve, reject) => {
+ // if publishInChannel is true, is a channel selected & logged in?
+ if (this.props.publishInChannel && (this.props.selectedChannel !== this.props.loggedInChannel.name)) {
+ // update state with error
+ this.props.onChannelSelectionError('Select "Anonymous" or log in to a channel');
+ // reject this promise
+ return reject(new Error('Fix the channel'));
+ }
+ });
+ }
+ validatePublishParams () {
// make sure all required data is provided
return new Promise((resolve, reject) => {
// is there a file?
@@ -28,10 +41,6 @@ class PublishForm extends React.Component {
if (this.props.urlError) {
return reject(new Error('Fix the url'));
}
- // if publishInChannel is true, is a channel logged in (or selected)
- if (this.props.publishInChannel && !this.props.loggedInChannel.name) {
- return reject(new Error('Select "Anonymous" or log in to a channel'));
- }
// is the claim available?
resolve();
});
@@ -85,7 +94,7 @@ class PublishForm extends React.Component {
thumbnail : this.props.thumbnail,
};
if (this.props.publishInChannel) {
- metadata['channelName'] = this.props.loggedInChannel.name;
+ metadata['channelName'] = this.props.selectedChannel;
}
return metadata;
}
@@ -103,7 +112,10 @@ class PublishForm extends React.Component {
publish () {
// publish the asset
const that = this;
- this.validatePublishRequest()
+ this.validateChannelSelection()
+ .then(() => {
+ return that.validatePublishRequest();
+ })
.then(() => {
const metadata = that.createMetadata();
// publish the claim
diff --git a/react/reducers/publish.js b/react/reducers/publish.js
index 108d84bf..1195a37d 100644
--- a/react/reducers/publish.js
+++ b/react/reducers/publish.js
@@ -12,6 +12,7 @@ const initialState = {
error: {
file : null,
url : null,
+ channel : null,
publishSubmit: null,
},
file : null,