mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-18 02:41:39 +03:00
support for favourite button action
This commit is contained in:
parent
82f19fe45b
commit
4745f19f07
@ -28,7 +28,6 @@ export const ActionPanel = ({isFollowing, isFavourite, onFavouritePress, onFollo
|
||||
name={'heart'}
|
||||
size={20}
|
||||
color={EStyleSheet.value(isFavourite?'$primaryRed':'$primaryBlack')}
|
||||
disabled={isFavourite}
|
||||
onPress={onFavouritePress}
|
||||
/>
|
||||
</View>
|
||||
|
@ -3,7 +3,7 @@ import { useIntl } from 'react-intl'
|
||||
import { View, Text, ActivityIndicator, Alert } from 'react-native'
|
||||
import { ProfileStats, StatsData } from './profileStats'
|
||||
import { MainButton, PercentBar } from '../../..'
|
||||
import { checkFavorite } from '../../../../providers/ecency/ecency'
|
||||
import { addFavorite, checkFavorite, deleteFavorite } from '../../../../providers/ecency/ecency'
|
||||
import { followUser, getFollows, getRelationship, getUser, unfollowUser } from '../../../../providers/hive/dhive'
|
||||
import { getRcPower, getVotingPower } from '../../../../utils/manaBar'
|
||||
import styles from './quickProfileStyles'
|
||||
@ -108,7 +108,7 @@ export const QuickProfileContent = ({
|
||||
};
|
||||
|
||||
|
||||
const _handleFollowUser = async () => {
|
||||
const _onFollowPress = async () => {
|
||||
try{
|
||||
const follower = currentAccountName
|
||||
const following = username;
|
||||
@ -137,16 +137,45 @@ export const QuickProfileContent = ({
|
||||
}
|
||||
}
|
||||
|
||||
const _onFavouritePress = async () => {
|
||||
try{
|
||||
setIsLoading(true);
|
||||
let favoriteAction;
|
||||
|
||||
if (isFavourite) {
|
||||
favoriteAction = deleteFavorite;
|
||||
} else {
|
||||
favoriteAction = addFavorite;
|
||||
}
|
||||
|
||||
await favoriteAction(username)
|
||||
|
||||
dispatch(
|
||||
toastNotification(
|
||||
intl.formatMessage({
|
||||
id: isFavourite ? 'alert.success_unfavorite' : 'alert.success_favorite',
|
||||
}),
|
||||
),
|
||||
);
|
||||
setIsFavourite(!isFavourite);
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
catch(error){
|
||||
console.warn('Failed to perform favorite action');
|
||||
setIsLoading(false);
|
||||
Alert.alert(
|
||||
intl.formatMessage({
|
||||
id: 'alert.fail',
|
||||
}),
|
||||
error.message || error.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//UI CALLBACKS
|
||||
const _onFollowPress = () => {
|
||||
_handleFollowUser()
|
||||
}
|
||||
|
||||
const _onFavouritePress = () => {
|
||||
|
||||
}
|
||||
|
||||
const _openFullProfile = () => {
|
||||
let params = {
|
||||
|
Loading…
Reference in New Issue
Block a user