Merge pull request #417 from esteemapp/bugfix/#414

fixed closed #414
This commit is contained in:
uğur erdal 2019-01-14 17:55:31 +03:00 committed by GitHub
commit 92f76a5813

View File

@ -26,6 +26,12 @@ import ProfileScreen from '../screen/profileScreen';
class ProfileContainer extends Component { class ProfileContainer extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
const isReverseHeader = !!(
props.navigation.state &&
props.navigation.state.params &&
props.navigation.state.username
);
this.state = { this.state = {
comments: [], comments: [],
follows: {}, follows: {},
@ -34,14 +40,14 @@ class ProfileContainer extends Component {
isMuted: false, isMuted: false,
isProfileLoading: false, isProfileLoading: false,
isReady: false, isReady: false,
isReverseHeader: !!(props.navigation.state && props.navigation.state.params), isReverseHeader,
user: null, user: null,
selectedQuickProfile: null, selectedQuickProfile: null,
}; };
} }
componentDidMount = () => { componentDidMount = () => {
const { navigation, isLoggedIn } = this.props; const { navigation, isLoggedIn, currentAccount } = this.props;
const selectedUser = navigation.state && navigation.state.params; const selectedUser = navigation.state && navigation.state.params;
if (!isLoggedIn && !selectedUser) { if (!isLoggedIn && !selectedUser) {
@ -49,7 +55,7 @@ class ProfileContainer extends Component {
return; return;
} }
if (selectedUser) { if (selectedUser && selectedUser.username) {
this._loadProfile(selectedUser.username); this._loadProfile(selectedUser.username);
if (selectedUser.username) { if (selectedUser.username) {
@ -62,6 +68,8 @@ class ProfileContainer extends Component {
} }
this.setState({ isReverseHeader: true }); this.setState({ isReverseHeader: true });
} else {
this._loadProfile(currentAccount.name);
} }
}; };
@ -69,12 +77,8 @@ class ProfileContainer extends Component {
const { const {
navigation, currentAccount, activeBottomTab, isLoggedIn, navigation, currentAccount, activeBottomTab, isLoggedIn,
} = this.props; } = this.props;
const currentUsername = currentAccount.name !== nextProps.currentAccount.name && nextProps.currentAccount.name; const currentUsername = currentAccount.name !== nextProps.currentAccount.name
const isParamsChange = nextProps.navigation.state && nextProps.currentAccount.name;
&& navigation.state
&& nextProps.navigation.state.params
&& nextProps.navigation.state.params.username
&& nextProps.navigation.state.params.username !== navigation.state.params.username;
if (isLoggedIn && !nextProps.isLoggedIn) { if (isLoggedIn && !nextProps.isLoggedIn) {
navigation.navigate(ROUTES.SCREENS.LOGIN); navigation.navigate(ROUTES.SCREENS.LOGIN);
@ -91,12 +95,6 @@ class ProfileContainer extends Component {
) { ) {
this._loadProfile(currentAccount.name); this._loadProfile(currentAccount.name);
} }
if (isParamsChange) {
const selectedUser = nextProps.navigation.state && nextProps.navigation.state.params;
this._loadProfile(selectedUser && selectedUser.username);
}
} }
_getReplies = async (user) => { _getReplies = async (user) => {