From 82f19fe45bf7f0ac26b6554fa71523c9b3936060 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Thu, 16 Sep 2021 12:53:37 +0500 Subject: [PATCH] removed support for unfollow --- .../children/actionPanel.tsx | 1 + .../children/quickProfileContent.tsx | 51 +++++++++---------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/components/organisms/quickProfileModal/children/actionPanel.tsx b/src/components/organisms/quickProfileModal/children/actionPanel.tsx index a68259344..d0e593f6a 100644 --- a/src/components/organisms/quickProfileModal/children/actionPanel.tsx +++ b/src/components/organisms/quickProfileModal/children/actionPanel.tsx @@ -19,6 +19,7 @@ export const ActionPanel = ({isFollowing, isFavourite, onFavouritePress, onFollo name={isFollowing?'user-following':'user-follow'} size={20} color={EStyleSheet.value('$primaryBlack')} + disabled={isFollowing} onPress={onFollowPress} /> { - const follower = currentAccountName - const following = username; - - let followAction; - - if (isFollowAction && !isFollowing) { - followAction = followUser; - } else { - followAction = unfollowUser; - } - - setIsLoading(true); - followAction(currentAccount, pinCode, { - follower, - following, - }) - .then(() => { + const _handleFollowUser = async () => { + try{ + const follower = currentAccountName + const following = username; + + setIsLoading(true); + await followUser(currentAccount, pinCode, { + follower, + following, + }) + setIsLoading(false); - setIsFollowing(isFollowAction) + setIsFollowing(true) dispatch( - toastNotification( + toastNotification( intl.formatMessage({ - id: isFollowing ? 'alert.success_unfollow' : 'alert.success_follow', + id: isFollowing ? 'alert.success_unfollow' : 'alert.success_follow', }), - ), + ), ); - }) - .catch((err) => { + } + catch(err){ setIsLoading(false); + console.warn("Failed to follow user", err) + Bugsnag.notify(err); Alert.alert(intl.formatMessage({id:'alert.fail'}), err.message) - }); - }; + } + } + //UI CALLBACKS const _onFollowPress = () => { - _handleFollowUnfollowUser(!isFollowing) + _handleFollowUser() } const _onFavouritePress = () => {