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