added support for reported user from dropdown

This commit is contained in:
Nouman Tahir 2021-10-01 21:41:24 +05:00
parent 73f724746b
commit ad1e750559
4 changed files with 69 additions and 8 deletions

View File

@ -97,6 +97,7 @@ class ProfileView extends PureComponent {
handleOnFavoritePress,
handleOnFollowsPress,
handleOnPressProfileEdit,
handleReportUser,
intl,
isDarkTheme,
isFavorite,
@ -137,6 +138,7 @@ class ProfileView extends PureComponent {
handleMuteUnmuteUser={handleMuteUnmuteUser}
handleOnFavoritePress={handleOnFavoritePress}
handleOnFollowsPress={handleOnFollowsPress}
handleReportUser={handleReportUser}
handleUIChange={this._handleUIChange}
hoursRC={Math.ceil((100 - resourceCredits) * 0.833333) || null}
hoursVP={Math.ceil((100 - votingPower) * 0.833333) || null}

View File

@ -57,7 +57,13 @@ class ProfileSummaryView extends PureComponent {
};
_handleOnDropdownSelect = (index) => {
const { isMuted, isFavorite, handleMuteUnmuteUser, handleOnFavoritePress } = this.props;
const {
isMuted,
isFavorite,
handleMuteUnmuteUser,
handleOnFavoritePress,
handleReportUser,
} = this.props;
switch (index) {
case 0:
@ -70,6 +76,11 @@ class ProfileSummaryView extends PureComponent {
handleMuteUnmuteUser(!isMuted);
}
break;
case 2:
if (handleReportUser) {
handleReportUser();
}
break;
default:
Alert.alert('Action not implemented');
break;
@ -101,7 +112,7 @@ class ProfileSummaryView extends PureComponent {
percentVP,
username,
} = this.props;
const dropdownOptions = [];
let dropdownOptions = [];
const votingPowerHoursText = hoursVP && `• Full in ${hoursVP} hours`;
const votingPowerText = `Voting power: ${percentVP}% ${votingPowerHoursText || ''}`;
const rcPowerHoursText = hoursRC && `• Full in ${hoursRC} hours`;
@ -133,16 +144,17 @@ class ProfileSummaryView extends PureComponent {
}
//compile dropdown options
dropdownOptions.push(
dropdownOptions = [
intl.formatMessage({
id: isFavorite ? 'user.remove_from_favourites' : 'user.add_to_favourites',
}),
);
dropdownOptions.push(
intl.formatMessage({
id: !isMuted ? 'user.mute' : 'user.unmute',
}),
);
intl.formatMessage({
id: 'user.report',
}),
];
return (
<Fragment>

View File

@ -20,11 +20,11 @@ import {
} from '../providers/hive/dhive';
// Ecency providers
import { checkFavorite, addFavorite, deleteFavorite } from '../providers/ecency/ecency';
import { checkFavorite, addFavorite, deleteFavorite, addReport } from '../providers/ecency/ecency';
// Utilitites
import { getRcPower, getVotingPower } from '../utils/manaBar';
import { toastNotification, setRcOffer } from '../redux/actions/uiAction';
import { toastNotification, setRcOffer, showActionModal } from '../redux/actions/uiAction';
// Constants
import { default as ROUTES } from '../constants/routeNames';
@ -407,6 +407,50 @@ class ProfileContainer extends Component {
});
};
_handleReportUser = () => {
const { dispatch, intl } = this.props;
const { username } = this.state;
const _onConfirm = () => {
addReport('user', username)
.then(() => {
dispatch(
toastNotification(
intl.formatMessage({
id: 'report.added',
}),
),
);
})
.catch(() => {
dispatch(
toastNotification(
intl.formatMessage({
id: 'report.added',
}),
),
);
});
};
dispatch(
showActionModal(
intl.formatMessage({ id: 'report.confirm_report_title' }),
intl.formatMessage({ id: 'report.confirm_report_body' }),
[
{
text: intl.formatMessage({ id: 'alert.cancel' }),
onPress: () => {},
},
{
text: intl.formatMessage({ id: 'alert.confirm' }),
onPress: _onConfirm,
},
],
),
);
};
_handleOnBackPress = () => {
const { navigation } = this.props;
const navigationParams = get(navigation.state, 'params');
@ -516,6 +560,7 @@ class ProfileContainer extends Component {
handleOnFavoritePress: this._handleOnFavoritePress,
handleOnFollowsPress: this._handleFollowsPress,
handleOnPressProfileEdit: this._handleOnPressProfileEdit,
handleReportUser: this._handleReportUser,
isDarkTheme,
isFavorite,
isFollowing,

View File

@ -24,6 +24,7 @@ const ProfileScreen = () => (
handleOnFavoritePress,
handleOnFollowsPress,
handleOnPressProfileEdit,
handleReportUser,
isDarkTheme,
isFavorite,
isFollowing,
@ -61,6 +62,7 @@ const ProfileScreen = () => (
handleOnFavoritePress={handleOnFavoritePress}
handleOnFollowsPress={handleOnFollowsPress}
handleOnPressProfileEdit={handleOnPressProfileEdit}
handleReportUser={handleReportUser}
isDarkTheme={isDarkTheme}
isFavorite={isFavorite}
isFollowing={isFollowing}