removed support for unfollow

This commit is contained in:
Nouman Tahir 2021-09-16 12:53:37 +05:00
parent 62ecaf24da
commit 82f19fe45b
2 changed files with 25 additions and 27 deletions

View File

@ -19,6 +19,7 @@ export const ActionPanel = ({isFollowing, isFavourite, onFavouritePress, onFollo
name={isFollowing?'user-following':'user-follow'} name={isFollowing?'user-following':'user-follow'}
size={20} size={20}
color={EStyleSheet.value('$primaryBlack')} color={EStyleSheet.value('$primaryBlack')}
disabled={isFollowing}
onPress={onFollowPress} onPress={onFollowPress}
/> />
<IconButton <IconButton

View File

@ -15,6 +15,7 @@ import moment from 'moment'
import { getTimeFromNow, getTimeFromNowNative } from '../../../../utils/time' import { getTimeFromNow, getTimeFromNowNative } from '../../../../utils/time'
import { useAppDispatch, useAppSelector } from '../../../../hooks' import { useAppDispatch, useAppSelector } from '../../../../hooks'
import { toastNotification } from '../../../../redux/actions/uiAction' import { toastNotification } from '../../../../redux/actions/uiAction'
import Bugsnag from '@bugsnag/react-native'
interface QuickProfileContentProps { interface QuickProfileContentProps {
username:string, username:string,
@ -107,44 +108,40 @@ export const QuickProfileContent = ({
}; };
const _handleFollowUnfollowUser = async (isFollowAction:boolean) => { const _handleFollowUser = async () => {
const follower = currentAccountName try{
const following = username; const follower = currentAccountName
const following = username;
let followAction;
setIsLoading(true);
if (isFollowAction && !isFollowing) { await followUser(currentAccount, pinCode, {
followAction = followUser; follower,
} else { following,
followAction = unfollowUser; })
}
setIsLoading(true);
followAction(currentAccount, pinCode, {
follower,
following,
})
.then(() => {
setIsLoading(false); setIsLoading(false);
setIsFollowing(isFollowAction) setIsFollowing(true)
dispatch( dispatch(
toastNotification( toastNotification(
intl.formatMessage({ intl.formatMessage({
id: isFollowing ? 'alert.success_unfollow' : 'alert.success_follow', id: isFollowing ? 'alert.success_unfollow' : 'alert.success_follow',
}), }),
), ),
); );
}) }
.catch((err) => { catch(err){
setIsLoading(false); setIsLoading(false);
console.warn("Failed to follow user", err)
Bugsnag.notify(err);
Alert.alert(intl.formatMessage({id:'alert.fail'}), err.message) Alert.alert(intl.formatMessage({id:'alert.fail'}), err.message)
}); }
}; }
//UI CALLBACKS //UI CALLBACKS
const _onFollowPress = () => { const _onFollowPress = () => {
_handleFollowUnfollowUser(!isFollowing) _handleFollowUser()
} }
const _onFavouritePress = () => { const _onFavouritePress = () => {