From 29c8399f0f6f82480606be21ffad7d0bab1e23cc Mon Sep 17 00:00:00 2001 From: u-e Date: Mon, 14 Jan 2019 11:53:20 +0300 Subject: [PATCH] fixed bclosed #414 --- .../profile/container/profileContainer.js | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/screens/profile/container/profileContainer.js b/src/screens/profile/container/profileContainer.js index a3afe6421..756765f63 100644 --- a/src/screens/profile/container/profileContainer.js +++ b/src/screens/profile/container/profileContainer.js @@ -26,6 +26,12 @@ import ProfileScreen from '../screen/profileScreen'; class ProfileContainer extends Component { constructor(props) { super(props); + const isReverseHeader = !!( + props.navigation.state && + props.navigation.state.params && + props.navigation.state.username + ); + this.state = { comments: [], follows: {}, @@ -34,14 +40,14 @@ class ProfileContainer extends Component { isMuted: false, isProfileLoading: false, isReady: false, - isReverseHeader: !!(props.navigation.state && props.navigation.state.params), + isReverseHeader, user: null, selectedQuickProfile: null, }; } componentDidMount = () => { - const { navigation, isLoggedIn } = this.props; + const { navigation, isLoggedIn, currentAccount } = this.props; const selectedUser = navigation.state && navigation.state.params; if (!isLoggedIn && !selectedUser) { @@ -49,7 +55,7 @@ class ProfileContainer extends Component { return; } - if (selectedUser) { + if (selectedUser && selectedUser.username) { this._loadProfile(selectedUser.username); if (selectedUser.username) { @@ -62,6 +68,8 @@ class ProfileContainer extends Component { } this.setState({ isReverseHeader: true }); + } else { + this._loadProfile(currentAccount.name); } }; @@ -69,12 +77,8 @@ class ProfileContainer extends Component { const { navigation, currentAccount, activeBottomTab, isLoggedIn, } = this.props; - const currentUsername = currentAccount.name !== nextProps.currentAccount.name && nextProps.currentAccount.name; - const isParamsChange = nextProps.navigation.state - && navigation.state - && nextProps.navigation.state.params - && nextProps.navigation.state.params.username - && nextProps.navigation.state.params.username !== navigation.state.params.username; + const currentUsername = currentAccount.name !== nextProps.currentAccount.name + && nextProps.currentAccount.name; if (isLoggedIn && !nextProps.isLoggedIn) { navigation.navigate(ROUTES.SCREENS.LOGIN); @@ -91,12 +95,6 @@ class ProfileContainer extends Component { ) { this._loadProfile(currentAccount.name); } - - if (isParamsChange) { - const selectedUser = nextProps.navigation.state && nextProps.navigation.state.params; - - this._loadProfile(selectedUser && selectedUser.username); - } } _getReplies = async (user) => {