fix text input error when channel list is empty

This commit is contained in:
Akinwale Ariwodola 2019-09-25 19:23:27 +01:00
parent 1b4c023c92
commit ca8670e23c

View file

@ -101,11 +101,13 @@ export default class ChannelCreator extends React.PureComponent {
generateAutoStyles = size => { generateAutoStyles = size => {
const { channels = [] } = this.props; const { channels = [] } = this.props;
const autoStyles = []; const autoStyles = [];
for (let i = 0; i < size && i < channels.length; i++) { if (channels) {
// seed generator using the claim_id for (let i = 0; i < size && i < channels.length; i++) {
const rng = seedrandom(channels[i].permanent_url); // is this efficient? // seed generator using the claim_id
const index = Math.floor(rng.quick() * ChannelIconItem.AUTO_THUMB_STYLES.length); const rng = seedrandom(channels[i].permanent_url); // is this efficient?
autoStyles.push(ChannelIconItem.AUTO_THUMB_STYLES[index]); const index = Math.floor(rng.quick() * ChannelIconItem.AUTO_THUMB_STYLES.length);
autoStyles.push(ChannelIconItem.AUTO_THUMB_STYLES[index]);
}
} }
return autoStyles; return autoStyles;
}; };
@ -478,12 +480,14 @@ export default class ChannelCreator extends React.PureComponent {
channelExists = name => { channelExists = name => {
const { channels = [] } = this.props; const { channels = [] } = this.props;
for (let channel of channels) { if (channels) {
if ( for (let channel of channels) {
name.toLowerCase() === channel.name.toLowerCase() || if (
`@${name}`.toLowerCase() === channel.name.toLowerCase() name.toLowerCase() === channel.name.toLowerCase() ||
) { `@${name}`.toLowerCase() === channel.name.toLowerCase()
return true; ) {
return true;
}
} }
} }
@ -868,7 +872,7 @@ export default class ChannelCreator extends React.PureComponent {
source={{ uri: thumbnailUrl }} source={{ uri: thumbnailUrl }}
/> />
)} )}
{(thumbnailUrl === null || thumbnailUrl.trim().length === 0) && newChannelName.length > 1 && ( {(thumbnailUrl === null || thumbnailUrl.trim().length === 0) && newChannelName.length > 0 && (
<Text style={channelIconStyle.autothumbCharacter}> <Text style={channelIconStyle.autothumbCharacter}>
{newChannelName.substring(0, 1).toUpperCase()} {newChannelName.substring(0, 1).toUpperCase()}
</Text> </Text>