From ca8670e23c3f4800dba57aa9374e0477dc5611b8 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Wed, 25 Sep 2019 19:23:27 +0100 Subject: [PATCH] fix text input error when channel list is empty --- src/page/channelCreator/view.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/page/channelCreator/view.js b/src/page/channelCreator/view.js index 65a9b0f..52ad762 100644 --- a/src/page/channelCreator/view.js +++ b/src/page/channelCreator/view.js @@ -101,11 +101,13 @@ export default class ChannelCreator extends React.PureComponent { generateAutoStyles = size => { const { channels = [] } = this.props; const autoStyles = []; - for (let i = 0; i < size && i < channels.length; i++) { - // seed generator using the claim_id - const rng = seedrandom(channels[i].permanent_url); // is this efficient? - const index = Math.floor(rng.quick() * ChannelIconItem.AUTO_THUMB_STYLES.length); - autoStyles.push(ChannelIconItem.AUTO_THUMB_STYLES[index]); + if (channels) { + for (let i = 0; i < size && i < channels.length; i++) { + // seed generator using the claim_id + const rng = seedrandom(channels[i].permanent_url); // is this efficient? + const index = Math.floor(rng.quick() * ChannelIconItem.AUTO_THUMB_STYLES.length); + autoStyles.push(ChannelIconItem.AUTO_THUMB_STYLES[index]); + } } return autoStyles; }; @@ -478,12 +480,14 @@ export default class ChannelCreator extends React.PureComponent { channelExists = name => { const { channels = [] } = this.props; - for (let channel of channels) { - if ( - name.toLowerCase() === channel.name.toLowerCase() || - `@${name}`.toLowerCase() === channel.name.toLowerCase() - ) { - return true; + if (channels) { + for (let channel of channels) { + if ( + name.toLowerCase() === channel.name.toLowerCase() || + `@${name}`.toLowerCase() === channel.name.toLowerCase() + ) { + return true; + } } } @@ -868,7 +872,7 @@ export default class ChannelCreator extends React.PureComponent { source={{ uri: thumbnailUrl }} /> )} - {(thumbnailUrl === null || thumbnailUrl.trim().length === 0) && newChannelName.length > 1 && ( + {(thumbnailUrl === null || thumbnailUrl.trim().length === 0) && newChannelName.length > 0 && ( {newChannelName.substring(0, 1).toUpperCase()}