From 04ec27f3335847d116f53c8ccb98e536a36fff6e Mon Sep 17 00:00:00 2001 From: enahum Date: Thu, 19 Oct 2017 13:07:46 -0300 Subject: [PATCH] Avoid crash on drawer filtered channel list (#1042) --- .../channels_list/channel_item/channel_item.js | 5 +++-- .../channel_drawer/channels_list/channel_item/index.js | 3 ++- .../channels_list/filtered_list/filtered_list.js | 10 +++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/components/channel_drawer/channels_list/channel_item/channel_item.js b/app/components/channel_drawer/channels_list/channel_item/channel_item.js index 2dac318f9..bd2bc46b4 100644 --- a/app/components/channel_drawer/channels_list/channel_item/channel_item.js +++ b/app/components/channel_drawer/channels_list/channel_item/channel_item.js @@ -19,6 +19,7 @@ export default class ChannelItem extends PureComponent { channelId: PropTypes.string.isRequired, currentChannelId: PropTypes.string.isRequired, displayName: PropTypes.string.isRequired, + fake: PropTypes.bool, isUnread: PropTypes.bool, mentions: PropTypes.number.isRequired, onSelectChannel: PropTypes.func.isRequired, @@ -28,9 +29,9 @@ export default class ChannelItem extends PureComponent { }; onPress = wrapWithPreventDoubleTap(() => { - const {channelId, currentChannelId, displayName, onSelectChannel} = this.props; + const {channelId, currentChannelId, displayName, fake, onSelectChannel, type} = this.props; requestAnimationFrame(() => { - onSelectChannel({id: channelId, display_name: displayName}, currentChannelId); + onSelectChannel({id: channelId, display_name: displayName, fake, type}, currentChannelId); }); }); diff --git a/app/components/channel_drawer/channels_list/channel_item/index.js b/app/components/channel_drawer/channels_list/channel_item/index.js index 775a75bf3..72b071814 100644 --- a/app/components/channel_drawer/channels_list/channel_item/index.js +++ b/app/components/channel_drawer/channels_list/channel_item/index.js @@ -12,7 +12,7 @@ function makeMapStateToProps() { const getChannel = makeGetChannel(); return (state, ownProps) => { - const channel = getChannel(state, {id: ownProps.channelId}); + const channel = ownProps.channel || getChannel(state, {id: ownProps.channelId}); let member; if (ownProps.isUnread) { member = getMyChannelMember(state, ownProps.channelId); @@ -21,6 +21,7 @@ function makeMapStateToProps() { return { currentChannelId: getCurrentChannelId(state), displayName: channel.display_name, + fake: channel.fake, mentions: member ? member.mention_count : 0, status: channel.status, theme: getTheme(state), diff --git a/app/components/channel_drawer/channels_list/filtered_list/filtered_list.js b/app/components/channel_drawer/channels_list/filtered_list/filtered_list.js index 44dbd1dcb..ff72ad444 100644 --- a/app/components/channel_drawer/channels_list/filtered_list/filtered_list.js +++ b/app/components/channel_drawer/channels_list/filtered_list/filtered_list.js @@ -95,25 +95,25 @@ class FilteredList extends Component { } onSelectChannel = (channel) => { - const {makeGroupMessageVisibleIfNecessary} = this.props.actions; + const {actions, currentChannel} = this.props; + const {makeGroupMessageVisibleIfNecessary} = actions; if (channel.type === General.GM_CHANNEL) { makeGroupMessageVisibleIfNecessary(channel.id); } - this.props.onSelectChannel(channel); + this.props.onSelectChannel(channel, currentChannel.id); }; createChannelElement = (channel) => { return ( ); };