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'}
|
name={'heart'}
|
||||||
size={20}
|
size={20}
|
||||||
color={EStyleSheet.value(isFavourite?'$primaryRed':'$primaryBlack')}
|
color={EStyleSheet.value(isFavourite?'$primaryRed':'$primaryBlack')}
|
||||||
disabled={isFavourite}
|
|
||||||
onPress={onFavouritePress}
|
onPress={onFavouritePress}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
@ -3,7 +3,7 @@ import { useIntl } from 'react-intl'
|
|||||||
import { View, Text, ActivityIndicator, Alert } from 'react-native'
|
import { View, Text, ActivityIndicator, Alert } from 'react-native'
|
||||||
import { ProfileStats, StatsData } from './profileStats'
|
import { ProfileStats, StatsData } from './profileStats'
|
||||||
import { MainButton, PercentBar } from '../../..'
|
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 { followUser, getFollows, getRelationship, getUser, unfollowUser } from '../../../../providers/hive/dhive'
|
||||||
import { getRcPower, getVotingPower } from '../../../../utils/manaBar'
|
import { getRcPower, getVotingPower } from '../../../../utils/manaBar'
|
||||||
import styles from './quickProfileStyles'
|
import styles from './quickProfileStyles'
|
||||||
@ -108,7 +108,7 @@ export const QuickProfileContent = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const _handleFollowUser = async () => {
|
const _onFollowPress = async () => {
|
||||||
try{
|
try{
|
||||||
const follower = currentAccountName
|
const follower = currentAccountName
|
||||||
const following = username;
|
const following = username;
|
||||||
@ -136,17 +136,46 @@ export const QuickProfileContent = ({
|
|||||||
Alert.alert(intl.formatMessage({id:'alert.fail'}), err.message)
|
Alert.alert(intl.formatMessage({id:'alert.fail'}), err.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
//UI CALLBACKS
|
||||||
const _onFollowPress = () => {
|
|
||||||
_handleFollowUser()
|
|
||||||
}
|
|
||||||
|
|
||||||
const _onFavouritePress = () => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const _openFullProfile = () => {
|
const _openFullProfile = () => {
|
||||||
let params = {
|
let params = {
|
||||||
|
Loading…
Reference in New Issue
Block a user