add protection (emoty object) when accessing id after declaring an object. (#1970)

This commit is contained in:
Saturnino Abril 2018-08-07 20:11:50 +08:00 committed by Elias Nahum
parent cf85c3c1e8
commit c1317f0e94
5 changed files with 5 additions and 5 deletions

View file

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

View file

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

View file

@ -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 {

View file

@ -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';

View file

@ -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 {