updated channel creation to check name availability directly

This commit is contained in:
bill bittner 2018-03-12 11:42:52 -07:00
parent 6297faac79
commit bbd455f4a1

View file

@ -45,6 +45,10 @@ class ChannelCreateForm extends React.Component {
this.setState({'error': error.message}); this.setState({'error': error.message});
}); });
} }
checkIsChannelAvailable (channel) {
const channelWithAtSymbol = `@${channel}`;
return request(`/api/channel/availability/${channelWithAtSymbol}`);
}
checkIsPasswordProvided () { checkIsPasswordProvided () {
const password = this.state.password; const password = this.state.password;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -77,9 +81,7 @@ class ChannelCreateForm extends React.Component {
event.preventDefault(); event.preventDefault();
this.checkIsPasswordProvided() this.checkIsPasswordProvided()
.then(() => { .then(() => {
if (this.state.error) { return this.checkIsChannelAvailable();
throw new Error();
}
}) })
.then(() => { .then(() => {
this.setState({status: 'We are publishing your new channel. Sit tight...'}); this.setState({status: 'We are publishing your new channel. Sit tight...'});