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,26 +108,19 @@ export const QuickProfileContent = ({
}; };
const _handleFollowUnfollowUser = async (isFollowAction:boolean) => { const _handleFollowUser = async () => {
try{
const follower = currentAccountName const follower = currentAccountName
const following = username; const following = username;
let followAction;
if (isFollowAction && !isFollowing) {
followAction = followUser;
} else {
followAction = unfollowUser;
}
setIsLoading(true); setIsLoading(true);
followAction(currentAccount, pinCode, { await followUser(currentAccount, pinCode, {
follower, follower,
following, following,
}) })
.then(() => {
setIsLoading(false); setIsLoading(false);
setIsFollowing(isFollowAction) setIsFollowing(true)
dispatch( dispatch(
toastNotification( toastNotification(
intl.formatMessage({ intl.formatMessage({
@ -134,17 +128,20 @@ export const QuickProfileContent = ({
}), }),
), ),
); );
}) }
.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 = () => {