diff --git a/src/components/header/view/headerView.js b/src/components/header/view/headerView.js index 5c36ce5f5..5ebbe6180 100644 --- a/src/components/header/view/headerView.js +++ b/src/components/header/view/headerView.js @@ -31,6 +31,26 @@ class HeaderView extends Component { // Component Functions + _getNameOfUser = () => { + const { currentAccount } = this.props; + if (Object.keys(currentAccount).length === 0) return currentAccount.name; + if (Object.keys(currentAccount.about).length === 0) return currentAccount.name; + if (Object.keys(currentAccount.about.profile).length !== 0) { + return currentAccount.about.profile.name; + } + return currentAccount.name; + }; + + _getUserAvatar = () => { + const { currentAccount } = this.props; + if (Object.keys(currentAccount).length === 0) return DEFAULT_IMAGE; + if (Object.keys(currentAccount.about).length === 0) return DEFAULT_IMAGE; + if (Object.keys(currentAccount.about.profile).length !== 0) { + return { uri: currentAccount.about.profile.profile_image }; + } + return DEFAULT_IMAGE; + }; + render() { const { handleOpenDrawer, @@ -38,10 +58,7 @@ class HeaderView extends Component { hideStatusBar, isReverse, currentAccount, - isLoggedIn, } = this.props; - const avatar = currentAccount && currentAccount.about && currentAccount.about.profile.profile_image; - const name = currentAccount && currentAccount.about && currentAccount.about.profile.name; return ( @@ -56,12 +73,16 @@ class HeaderView extends Component { isReverse ? styles.avatarButtonWrapperReverse : styles.avatarDefault, ]} > - + {currentAccount && currentAccount.name ? ( - { name && {name} } + {this._getNameOfUser()} @ {currentAccount.name} diff --git a/src/components/sideMenu/view/sideMenuView.js b/src/components/sideMenu/view/sideMenuView.js index d22ade08a..a2ebcf9e1 100644 --- a/src/components/sideMenu/view/sideMenuView.js +++ b/src/components/sideMenu/view/sideMenuView.js @@ -40,6 +40,9 @@ class SideMenuView extends Component { }); } + + // Component Functions + _handleOnPressAddAccountIcon = () => { const { isAddAccountIconActive } = this.state; const { isLoggedIn, accounts } = this.props; @@ -53,15 +56,31 @@ class SideMenuView extends Component { } }; - // Component Functions + _getNameOfUser = () => { + const { currentAccount } = this.props; + if (Object.keys(currentAccount).length === 0) return currentAccount.name; + if (Object.keys(currentAccount.about).length === 0) return currentAccount.name; + if (Object.keys(currentAccount.about.profile).length !== 0) { + return currentAccount.about.profile.name; + } + return currentAccount.name; + }; + + _getUserAvatar = () => { + const { currentAccount } = this.props; + if (Object.keys(currentAccount).length === 0) return DEFAULT_IMAGE; + if (Object.keys(currentAccount.about).length === 0) return DEFAULT_IMAGE; + if (Object.keys(currentAccount.about.profile).length !== 0) { + return { uri: currentAccount.about.profile.profile_image }; + } + return DEFAULT_IMAGE; + }; render() { const { navigateToRoute, currentAccount, isLoggedIn, switchAccount, } = this.props; const { menuItems, isAddAccountIconActive } = this.state; - const avatar = currentAccount && currentAccount.about && currentAccount.about.profile.profile_image; - const name = currentAccount && currentAccount.about && currentAccount.about.profile.name; return ( @@ -73,9 +92,9 @@ class SideMenuView extends Component { > {isLoggedIn && ( - + - {name} + {this._getNameOfUser()} {`@${currentAccount.name}`}