From a81701092d0af53d0bf8c4d73eb21f2f1045a09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Fri, 4 Jan 2019 08:53:36 +0100 Subject: [PATCH] Handling nulls in getMyCurrentChannelMembership (#2488) --- app/screens/channel/channel_post_list/index.js | 3 ++- app/screens/thread/thread.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/screens/channel/channel_post_list/index.js b/app/screens/channel/channel_post_list/index.js index f18570cf6..74705d22e 100644 --- a/app/screens/channel/channel_post_list/index.js +++ b/app/screens/channel/channel_post_list/index.js @@ -18,6 +18,7 @@ import ChannelPostList from './channel_post_list'; function mapStateToProps(state) { const channelId = getCurrentChannelId(state); const channelRefreshingFailed = state.views.channel.retryFailed; + const currentChannelMember = getMyCurrentChannelMembership(state); return { channelId, @@ -26,7 +27,7 @@ function mapStateToProps(state) { deviceHeight: state.device.dimension.deviceHeight, postIds: getPostIdsInCurrentChannel(state), postVisibility: state.views.channel.postVisibility[channelId], - lastViewedAt: getMyCurrentChannelMembership(state).last_viewed_at, + lastViewedAt: currentChannelMember && currentChannelMember.last_viewed_at, loadMorePostsVisible: state.views.channel.loadMorePostsVisible, refreshing: state.views.channel.refreshing, theme: getTheme(state), diff --git a/app/screens/thread/thread.js b/app/screens/thread/thread.js index 9c8b57022..aa678822d 100644 --- a/app/screens/thread/thread.js +++ b/app/screens/thread/thread.js @@ -66,7 +66,7 @@ export default class Thread extends PureComponent { } if (!this.state.lastViewedAt) { - this.setState({lastViewedAt: nextProps.myMember.last_viewed_at}); + this.setState({lastViewedAt: nextProps.myMember && nextProps.myMember.last_viewed_at}); } } @@ -145,7 +145,7 @@ export default class Thread extends PureComponent { renderFooter={this.renderFooter()} indicateNewMessages={true} postIds={postIds} - currentUserId={myMember.user_id} + currentUserId={myMember && myMember.user_id} lastViewedAt={this.state.lastViewedAt} navigator={navigator} />