diff --git a/app/actions/views/channel.js b/app/actions/views/channel.js index be0f4b3cb..8365a9122 100644 --- a/app/actions/views/channel.js +++ b/app/actions/views/channel.js @@ -259,8 +259,11 @@ export function selectInitialChannel(teamId) { const isGMVisible = lastChannel && lastChannel.type === General.GM_CHANNEL && isGroupChannelVisible(myPreferences, lastChannel); - if (lastChannelId && myMembers[lastChannelId] && - (lastChannel.team_id === teamId || isDMVisible || isGMVisible)) { + if ( + myMembers[lastChannelId] && + lastChannel && + (lastChannel.team_id === teamId || isDMVisible || isGMVisible) + ) { handleSelectChannel(lastChannelId)(dispatch, getState); markChannelAsRead(lastChannelId)(dispatch, getState); return; diff --git a/app/actions/views/root.js b/app/actions/views/root.js index aea994297..5788e3613 100644 --- a/app/actions/views/root.js +++ b/app/actions/views/root.js @@ -55,10 +55,15 @@ export function loadFromPushNotification(notification) { const {data} = notification; const {currentTeamId, teams, myMembers: myTeamMembers} = state.entities.teams; const {currentChannelId, channels} = state.entities.channels; - 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; + let channelId = ''; + let teamId = currentTeamId; + if (data) { + channelId = data.channel_id; + + // when the notification does not have a team id is because its from a DM or GM + teamId = data.team_id || currentTeamId; + } // load any missing data const loading = []; diff --git a/app/components/reactions/index.js b/app/components/reactions/index.js index 48f0896cd..d29458654 100644 --- a/app/components/reactions/index.js +++ b/app/components/reactions/index.js @@ -22,7 +22,7 @@ function makeMapStateToProps() { return function mapStateToProps(state, ownProps) { const post = getPost(state, ownProps.postId); const channelId = post ? post.channel_id : ''; - const channel = getChannel(state, channelId); + const channel = getChannel(state, channelId) || {}; const teamId = channel.team_id; const channelIsArchived = channel.delete_at !== 0;