diff --git a/app/actions/views/root.js b/app/actions/views/root.js index 3a831f54e..aea994297 100644 --- a/app/actions/views/root.js +++ b/app/actions/views/root.js @@ -55,7 +55,7 @@ export function loadFromPushNotification(notification) { const {data} = notification; const {currentTeamId, teams, myMembers: myTeamMembers} = state.entities.teams; const {currentChannelId, channels} = state.entities.channels; - const channelId = data.channel_id; + const channelId = data ? data.channel_id : ''; // when the notification does not have a team id is because its from a DM or GM const teamId = data.team_id || currentTeamId; diff --git a/app/components/post_body/index.js b/app/components/post_body/index.js index 4d654f92f..ca5ba7fb5 100644 --- a/app/components/post_body/index.js +++ b/app/components/post_body/index.js @@ -32,7 +32,7 @@ import PostBody from './post_body'; const POST_TIMEOUT = 20000; function mapStateToProps(state, ownProps) { - const post = getPost(state, ownProps.postId); + const post = getPost(state, ownProps.postId) || {}; const channel = getChannel(state, post.channel_id) || {}; const channelIsArchived = channel ? channel.delete_at !== 0 : false; const teamId = channel.team_id; diff --git a/app/components/reactions/index.js b/app/components/reactions/index.js index 4ec98224d..48f0896cd 100644 --- a/app/components/reactions/index.js +++ b/app/components/reactions/index.js @@ -21,7 +21,8 @@ function makeMapStateToProps() { const getReactionsForPostSelector = makeGetReactionsForPost(); return function mapStateToProps(state, ownProps) { const post = getPost(state, ownProps.postId); - const channel = getChannel(state, post.channel_id) || {}; + const channelId = post ? post.channel_id : ''; + const channel = getChannel(state, channelId); const teamId = channel.team_id; const channelIsArchived = channel.delete_at !== 0; @@ -33,12 +34,12 @@ function makeMapStateToProps() { } else if (hasNewPermissions(state)) { canAddReaction = haveIChannelPermission(state, { team: teamId, - channel: post.channel_id, + channel: channelId, permission: Permissions.ADD_REACTION, }); canRemoveReaction = haveIChannelPermission(state, { team: teamId, - channel: post.channel_id, + channel: channelId, permission: Permissions.REMOVE_REACTION, }); } diff --git a/app/components/root/root.js b/app/components/root/root.js index bb202968b..a4438a0f9 100644 --- a/app/components/root/root.js +++ b/app/components/root/root.js @@ -51,7 +51,7 @@ export default class Root extends PureComponent { const {data} = notification; const {currentChannelId, navigator} = this.props; - if (data.channel_id !== currentChannelId) { + if (data && data.channel_id !== currentChannelId) { navigator.showInAppNotification({ screen: 'Notification', position: 'top', diff --git a/app/screens/permalink/permalink.js b/app/screens/permalink/permalink.js index a66969581..8b811e5aa 100644 --- a/app/screens/permalink/permalink.js +++ b/app/screens/permalink/permalink.js @@ -269,8 +269,9 @@ export default class Permalink extends PureComponent { } if (!channelId) { - focusChannelId = post.data.posts[focusedPostId].channel_id; - if (!this.props.myMembers[focusChannelId]) { + const focusedPost = post.data.posts[focusedPostId]; + focusChannelId = focusedPost ? focusedPost.channel_id : ''; + if (focusChannelId && !this.props.myMembers[focusChannelId]) { const {data: channel} = await actions.getChannel(focusChannelId); if (channel && channel.type === General.OPEN_CHANNEL) { await actions.joinChannel(currentUserId, channel.team_id, channel.id); diff --git a/app/screens/search/channel_display_name/index.js b/app/screens/search/channel_display_name/index.js index c0fede347..9a08008f9 100644 --- a/app/screens/search/channel_display_name/index.js +++ b/app/screens/search/channel_display_name/index.js @@ -13,7 +13,7 @@ function makeMapStateToProps() { const getChannel = makeGetChannel(); return (state, ownProps) => { const post = getPost(state, ownProps.postId); - const channel = getChannel(state, {id: post.channel_id}); + const channel = post ? getChannel(state, {id: post.channel_id}) : null; return { displayName: channel ? channel.display_name : '',