auto-select channel upon creation

This commit is contained in:
Akinwale Ariwodola 2019-08-20 10:11:35 +01:00
parent 6ae8c32f72
commit 719604e7da
2 changed files with 10 additions and 13 deletions

View file

@ -37,13 +37,11 @@ export default class ChannelSelector extends React.PureComponent {
}; };
handlePickerValueChange = (itemValue, itemIndex) => { handlePickerValueChange = (itemValue, itemIndex) => {
if (Constants.ITEM_CREATE_A_CHANNEL === itemValue.name) { if (Constants.ITEM_CREATE_A_CHANNEL === itemValue) {
this.setState({ showCreateChannel: true }); this.setState({ showCreateChannel: true });
} else { } else {
this.handleCreateCancel(); this.handleCreateCancel();
this.handleChannelChange( this.handleChannelChange(Constants.ITEM_ANONYMOUS === itemValue ? CLAIM_VALUES.CHANNEL_ANONYMOUS : itemValue);
Constants.ITEM_ANONYMOUS === itemValue.name ? { name: CLAIM_VALUES.CHANNEL_ANONYMOUS } : itemValue
);
} }
this.setState({ currentSelectedValue: itemValue }); this.setState({ currentSelectedValue: itemValue });
}; };
@ -51,7 +49,7 @@ export default class ChannelSelector extends React.PureComponent {
handleChannelChange = value => { handleChannelChange = value => {
const { onChannelChange } = this.props; const { onChannelChange } = this.props;
const { newChannelBid } = this.state; const { newChannelBid } = this.state;
const channel = value.name; const channel = value;
if (channel === CLAIM_VALUES.CHANNEL_NEW) { if (channel === CLAIM_VALUES.CHANNEL_NEW) {
this.setState({ addingChannel: true }); this.setState({ addingChannel: true });
@ -174,9 +172,7 @@ export default class ChannelSelector extends React.PureComponent {
render() { render() {
const channel = this.state.addingChannel ? 'new' : this.props.channel; const channel = this.state.addingChannel ? 'new' : this.props.channel;
const { fetchingChannels, channels = [] } = this.props; const { fetchingChannels, channels = [] } = this.props;
const pickerItems = [{ name: Constants.ITEM_ANONYMOUS }, { name: Constants.ITEM_CREATE_A_CHANNEL }].concat( const pickerItems = [Constants.ITEM_ANONYMOUS, Constants.ITEM_CREATE_A_CHANNEL].concat(channels.map(ch => ch.name));
channels
);
const { const {
newChannelName, newChannelName,
@ -198,7 +194,7 @@ export default class ChannelSelector extends React.PureComponent {
onValueChange={this.handlePickerValueChange} onValueChange={this.handlePickerValueChange}
> >
{pickerItems.map(item => ( {pickerItems.map(item => (
<Picker.Item label={item.name} value={item} key={item.name} /> <Picker.Item label={item} value={item} key={item} />
))} ))}
</Picker> </Picker>

View file

@ -254,8 +254,9 @@ class PublishPage extends React.PureComponent {
}, },
}; };
updatePublishForm(publishParams); console.log(publishParams);
this.setState({ publishStarted: true }, () => publish(this.handlePublishSuccess, this.handlePublishFailure)); // updatePublishForm(publishParams);
// this.setState({ publishStarted: true }, () => publish(this.handlePublishSuccess, this.handlePublishFailure));
}; };
handlePublishSuccess = data => { handlePublishSuccess = data => {
@ -471,8 +472,8 @@ class PublishPage extends React.PureComponent {
handleChannelChange = channel => { handleChannelChange = channel => {
const { name } = this.state; const { name } = this.state;
const uri = this.getNewUri(name, channel.name); const uri = this.getNewUri(name, channel);
this.setState({ uri, channelName: channel.name, selectedChannel: channel }); this.setState({ uri, channelName: channel, selectedChannel: channel });
}; };
handleAddTag = tag => { handleAddTag = tag => {