Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

make trash work properly

ammarahm-ed12be797c6184
diff --git a/apps/mobile/src/components/ActionSheetComponent/index.js b/apps/mobile/src/components/ActionSheetComponent/index.js
index 633fcc83e..0edbf6cd4 100644
--- a/apps/mobile/src/components/ActionSheetComponent/index.js
+++ b/apps/mobile/src/components/ActionSheetComponent/index.js
@@ -272,7 +272,7 @@ export const ActionSheetComponent = ({
name: 'Remove',
icon: 'delete',
func: () => {
- close();
+ close('permanant_delete');
},
},
];
diff --git a/apps/mobile/src/components/Dialog/index.js b/apps/mobile/src/components/Dialog/index.js
index 772922f20..c3bd69006 100644
--- a/apps/mobile/src/components/Dialog/index.js
+++ b/apps/mobile/src/components/Dialog/index.js
@@ -75,6 +75,21 @@ export class Dialog extends Component {
}
break;
}
+ case dialogActions.ACTION_PERMANANT_DELETE: {
+ if (item.dateCreated && history.selectedItemsList.length === 0) {
+ history.selectedItemsList = [];
+ history.selectedItemsList.push(item);
+ }
+ let ids = [];
+ history.selectedItemsList.forEach(item => ids.push(item.id));
+
+ await db.trash.delete(...ids);
+ updateEvent({type: ACTIONS.TRASH});
+ updateEvent({type: ACTIONS.CLEAR_SELECTION});
+ updateEvent({type: ACTIONS.SELECTION_MODE, enabled: false});
+ ToastEvent.show('Item permanantly deleted');
+ break;
+ }
case dialogActions.ACTION_EXIT: {
this.setState({
visible: false,
@@ -86,7 +101,10 @@ export class Dialog extends Component {
case dialogActions.ACTION_EMPTY_TRASH: {
await db.trash.clear();
updateEvent({type: ACTIONS.TRASH});
- ToastEvent.show('Trash cleared', 'error', 1000, () => {}, '');
+
+ updateEvent({type: ACTIONS.CLEAR_SELECTION});
+ updateEvent({type: ACTIONS.SELECTION_MODE, enabled: false});
+ ToastEvent.show('Trash cleared', 'error');
this.setState({
visible: false,
});
diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.js
index 557dada36..23c35ddf2 100644
--- a/apps/mobile/src/components/DialogManager/index.js
+++ b/apps/mobile/src/components/DialogManager/index.js
@@ -40,6 +40,7 @@ export const dialogActions = {
ACTION_EMPTY_TRASH: 513,
ACTION_EXIT_FULLSCREEN: 514,
ACTION_TRASH: 515,
+ ACTION_PERMANANT_DELETE: 516,
};
export const ActionSheetEvent = (
@@ -106,6 +107,15 @@ export const TEMPLATE_DELETE = type => {
};
};
+export const TEMPLATE_PERMANANT_DELETE = {
+ title: `Delete Permanantly`,
+ paragraph: `Are you sure you want to delete this item permanantly from trash?`,
+ positiveText: 'Delete',
+ negativeText: 'Cancel',
+ action: dialogActions.ACTION_PERMANANT_DELETE,
+ icon: 'delete',
+};
+
export const TEMPLATE_TRASH = type => {
return {
title: `Delete ${type}`,
@@ -348,6 +358,10 @@ export class DialogManager extends Component {
this._showSimpleDialog(TEMPLATE_DELETE(this.state.item.type));
break;
}
+ case 'permanant_delete': {
+ this._showSimpleDialog(TEMPLATE_PERMANANT_DELETE);
+ break;
+ }
case 'lock': {
this._showVaultDialog();
break;