From 21bea1ab985bdd6bb768a531c49c241c5d9d87a1 Mon Sep 17 00:00:00 2001 From: Mustafa Buyukcelebi Date: Tue, 13 Aug 2019 21:15:01 +0300 Subject: [PATCH] Added click action for user avatar on side menu --- src/components/sideMenu/view/sideMenuView.js | 1 - src/components/userAvatar/view/userAvatarView.js | 14 ++++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/sideMenu/view/sideMenuView.js b/src/components/sideMenu/view/sideMenuView.js index 244f0b682..4f4525fd3 100644 --- a/src/components/sideMenu/view/sideMenuView.js +++ b/src/components/sideMenu/view/sideMenuView.js @@ -109,7 +109,6 @@ class SideMenuView extends Component { username={currentAccount.username} size="xl" style={styles.userAvatar} - noAction /> {currentAccount.display_name && ( diff --git a/src/components/userAvatar/view/userAvatarView.js b/src/components/userAvatar/view/userAvatarView.js index 4c25f2d93..5efbf6920 100644 --- a/src/components/userAvatar/view/userAvatarView.js +++ b/src/components/userAvatar/view/userAvatarView.js @@ -26,15 +26,17 @@ class UserAvatarView extends Component { // Component Functions _handleOnAvatarPress = username => { - const { dispatch } = this.props; + const { dispatch, currentUsername } = this.props; + + const routeName = currentUsername === username ? ROUTES.TABBAR.PROFILE : ROUTES.SCREENS.PROFILE; const navigateAction = NavigationActions.navigate({ - routeName: ROUTES.SCREENS.PROFILE, + routeName, params: { username, }, key: username, - action: NavigationActions.navigate({ routeName: ROUTES.SCREENS.PROFILE }), + action: NavigationActions.navigate({ routeName }), }); dispatch(navigateAction); }; @@ -70,4 +72,8 @@ class UserAvatarView extends Component { } } -export default connect()(UserAvatarView); +const mapStateToProps = state => ({ + currentUsername: state.account.currentAccount.name, +}); + +export default connect(mapStateToProps)(UserAvatarView);