Handling nulls in getMyCurrentChannelMembership (#2488)

This commit is contained in:
Jesús Espino 2019-01-04 08:53:36 +01:00 committed by GitHub
parent 37d16d4cbc
commit a81701092d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -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),

View file

@ -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}
/>