From c1317f0e94e1b340b62ddc72164d7f86051fef42 Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Tue, 7 Aug 2018 20:11:50 +0800 Subject: [PATCH] add protection (emoty object) when accessing id after declaring an object. (#1970) --- app/components/combined_system_message/index.js | 2 +- .../sidebars/main/channels_list/switch_teams_button/index.js | 2 +- app/components/sidebars/settings/index.js | 2 +- app/screens/settings/notification_settings/index.js | 2 +- app/screens/timezone/index.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/components/combined_system_message/index.js b/app/components/combined_system_message/index.js index 7ccee01ea..70b14c446 100644 --- a/app/components/combined_system_message/index.js +++ b/app/components/combined_system_message/index.js @@ -15,7 +15,7 @@ function makeMapStateToProps() { const getProfilesByIdsAndUsernames = makeGetProfilesByIdsAndUsernames(); return (state, ownProps) => { - const currentUser = getCurrentUser(state); + const currentUser = getCurrentUser(state) || {}; const {allUserIds, allUsernames} = ownProps; return { currentUserId: currentUser.id, diff --git a/app/components/sidebars/main/channels_list/switch_teams_button/index.js b/app/components/sidebars/main/channels_list/switch_teams_button/index.js index aff581356..825e93234 100644 --- a/app/components/sidebars/main/channels_list/switch_teams_button/index.js +++ b/app/components/sidebars/main/channels_list/switch_teams_button/index.js @@ -9,7 +9,7 @@ import {getCurrentTeam, getMyTeamsCount, getChannelDrawerBadgeCount} from 'matte import SwitchTeamsButton from './switch_teams_button'; function mapStateToProps(state) { - const team = getCurrentTeam(state); + const team = getCurrentTeam(state) || {}; return { currentTeamId: team.id, diff --git a/app/components/sidebars/settings/index.js b/app/components/sidebars/settings/index.js index 4e4b8f263..0ce0f01f7 100644 --- a/app/components/sidebars/settings/index.js +++ b/app/components/sidebars/settings/index.js @@ -13,7 +13,7 @@ import {getDimensions} from 'app/selectors/device'; import SettingsSidebar from './settings_sidebar'; function mapStateToProps(state) { - const currentUser = getCurrentUser(state); + const currentUser = getCurrentUser(state) || {}; const status = getStatusForUserId(state, currentUser.id); return { diff --git a/app/screens/settings/notification_settings/index.js b/app/screens/settings/notification_settings/index.js index d41937991..71673b63d 100644 --- a/app/screens/settings/notification_settings/index.js +++ b/app/screens/settings/notification_settings/index.js @@ -15,7 +15,7 @@ import NotificationSettings from './notification_settings'; function mapStateToProps(state) { const config = getConfig(state); - const currentUser = getCurrentUser(state); + const currentUser = getCurrentUser(state) || {}; const currentUserStatus = getStatusForUserId(state, currentUser.id); const serverVersion = state.entities.general.serverVersion; const enableAutoResponder = isMinimumServerVersion(serverVersion, 4, 9) && config.ExperimentalEnableAutomaticReplies === 'true'; diff --git a/app/screens/timezone/index.js b/app/screens/timezone/index.js index 19e7280b4..fb2901c89 100644 --- a/app/screens/timezone/index.js +++ b/app/screens/timezone/index.js @@ -16,7 +16,7 @@ import Timezone from './timezone'; function mapStateToProps(state) { const timezones = getTimezones(state); - const currentUser = getCurrentUser(state); + const currentUser = getCurrentUser(state) || {}; const userTimezone = getUserTimezone(state, currentUser.id); return {