Commit 7ad581c4 authored by Martin Santangelo's avatar Martin Santangelo

(fix) activity delete option is not working

......@@ -32,6 +32,15 @@ export default class ActivityActionSheet extends Component {
userBlocked: false
}
/**
* Constructor
* @param {Object} props
*/
constructor(props) {
super(props);
this.deleteOption = <Text style={[CS.colorDanger, CS.fontXL]}>{i18n.t('delete')}</Text>
}
/**
* Show menu
*/
......@@ -51,7 +60,7 @@ export default class ActivityActionSheet extends Component {
*/
handleSelection = (index) => {
if (!this.state.options[index]) return;
this.executeAction(this.state.options[index]);
this.executeAction(this.state.options[index], index);
}
/**
......@@ -110,7 +119,7 @@ export default class ActivityActionSheet extends Component {
// if can delete
if (entity.can(FLAG_DELETE_POST)) {
options.push(<Text style={[CS.colorDanger, CS.fontXL]}>{i18n.t('delete')}</Text>);
options.push(this.deleteOption);
}
} else {
// if can edit
......@@ -160,7 +169,7 @@ export default class ActivityActionSheet extends Component {
// if can delete
if (entity.isOwner() || sessionService.getUser().isAdmin()) {
options.push(<Text style={[CS.colorDanger, CS.fontXL]}>{i18n.t('delete')}</Text>);
options.push(this.deleteOption);
}
}
......@@ -211,23 +220,26 @@ export default class ActivityActionSheet extends Component {
*/
async executeAction(option) {
switch (option) {
case this.deleteOption:
setTimeout(() => {
Alert.alert(
i18n.t('delete'),
i18n.t('confirmNoUndo'),
[
{text: i18n.t('cancel'), style: 'cancel'},
{text: i18n.t('ok'), onPress: () => this.deleteEntity()},
],
{ cancelable: false }
);
return;
}, 300);
break;
case i18n.t('translate.translate'):
if (this.props.onTranslate) this.props.onTranslate();
break;
case i18n.t('edit'):
this.props.toggleEdit(true);
break;
case i18n.t('delete'):
Alert.alert(
i18n.t('delete'),
i18n.t('confirmNoUndo'),
[
{text: i18n.t('cancel'), style: 'cancel'},
{text: i18n.t('ok'), onPress: () => this.deleteEntity()},
],
{ cancelable: false }
)
break;
case i18n.t('setExplicit'):
case i18n.t('removeExplicit'):
try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment