diff --git a/src/components/profileSummary/view/profileSummaryView.js b/src/components/profileSummary/view/profileSummaryView.js index 2ba0b0f35..e9a0358e4 100644 --- a/src/components/profileSummary/view/profileSummaryView.js +++ b/src/components/profileSummary/view/profileSummaryView.js @@ -71,6 +71,7 @@ class ProfileSummaryView extends PureComponent { hoursVP, intl, isDarkTheme, + isFavorite, isFollowing, isLoggedIn, isMuted, @@ -116,7 +117,14 @@ class ProfileSummaryView extends PureComponent { iconType="MaterialCommunityIcons" /> )} - {!!date && } + {!!date && ( + + )} - {isLoggedIn && ( + {isLoggedIn && !isOwnProfile && ( - {!isOwnProfile && ( - - - {isProfileLoading ? ( - - ) : ( - handleFollowUnfollowUser(!isFollowing)} - size={20} - color="#c1c5c7" - /> - )} - {isProfileLoading ? ( - - ) : ( - - )} - + + {isProfileLoading ? ( + + ) : ( + handleFollowUnfollowUser(!isFollowing)} + size={20} + /> + )} + {isProfileLoading ? ( + + ) : ( + )} )} diff --git a/src/providers/esteem/esteem.js b/src/providers/esteem/esteem.js index ac192e76f..f7f07cee3 100644 --- a/src/providers/esteem/esteem.js +++ b/src/providers/esteem/esteem.js @@ -100,7 +100,7 @@ export const getFavorites = username => api.get(`/favorites/${username}`).then(r * @params current username * @params target username */ -export const isFavorite = (currentUsername, targetUsername) => api.get(`/isfavorite/${currentUsername}/${targetUsername}`).then(resp => resp.data); +export const getIsFavorite = (targetUsername, currentUsername) => api.get(`/isfavorite/${currentUsername}/${targetUsername}`).then(resp => resp.data); /** * @params current username diff --git a/src/screens/profile/container/profileContainer.js b/src/screens/profile/container/profileContainer.js index 459588ca5..a6b291ff0 100644 --- a/src/screens/profile/container/profileContainer.js +++ b/src/screens/profile/container/profileContainer.js @@ -2,7 +2,7 @@ import React, { Component, Fragment } from 'react'; import { connect } from 'react-redux'; import { withNavigation } from 'react-navigation'; -// Utilitites +// Providers import { followUser, unfollowUser, @@ -14,6 +14,9 @@ import { getIsMuted, } from '../../../providers/steem/dsteem'; +// Esteem providers +import { getIsFavorite } from '../../../providers/esteem/esteem'; + // Constants import { default as ROUTES } from '../../../constants/routeNames'; @@ -26,6 +29,7 @@ class ProfileContainer extends Component { this.state = { comments: [], follows: {}, + isFavorite: false, isFollowing: false, isMuted: false, isProfileLoading: false, @@ -194,12 +198,15 @@ class ProfileContainer extends Component { const { isLoggedIn, currentAccount } = this.props; let _isFollowing; let _isMuted; + let _isFavorite; let _follows; - if (isLoggedIn) { + if (isLoggedIn && currentAccount.name !== username) { _isFollowing = await getIsFollowing(username, currentAccount.name); _isMuted = _isFollowing ? false : await getIsMuted(username, currentAccount.name); + + _isFavorite = getIsFavorite(username, currentAccount.name); } await getFollows(username).then((res) => { @@ -210,6 +217,7 @@ class ProfileContainer extends Component { follows: _follows, isFollowing: _isFollowing, isMuted: _isMuted, + isFavorite: _isFavorite, }); } }; @@ -262,18 +270,19 @@ class ProfileContainer extends Component { render() { const { + avatar, comments, error, follows, - isProfileLoading, + isFavorite, isFollowing, isMuted, + isProfileLoading, isReady, isReverseHeader, + selectedQuickProfile, user, username, - avatar, - selectedQuickProfile, } = this.state; const { isDarkTheme, isLoggedIn } = this.props; @@ -282,7 +291,6 @@ class ProfileContainer extends Component { diff --git a/src/screens/profile/screen/profileScreen.js b/src/screens/profile/screen/profileScreen.js index e92bd01f9..272edb031 100644 --- a/src/screens/profile/screen/profileScreen.js +++ b/src/screens/profile/screen/profileScreen.js @@ -61,6 +61,7 @@ class ProfileScreen extends PureComponent { handleOnFollowsPress, intl, isDarkTheme, + isFavorite, isFollowing, isLoggedIn, isMuted, @@ -133,6 +134,7 @@ class ProfileScreen extends PureComponent { intl={intl} isDarkTheme={isDarkTheme} isFollowing={isFollowing} + isFavorite={isFavorite} isLoggedIn={isLoggedIn} isMuted={isMuted} isOwnProfile={!isReverseHeader} @@ -195,11 +197,7 @@ class ProfileScreen extends PureComponent { id: 'profile.wallet', })} > - {selectedUser ? ( - - ) : ( - - )} + {selectedUser ? : }