Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile: Resolves #10092: Added empty trash option on long pressing the trash folder. #10120

Merged
merged 13 commits into from Mar 14, 2024
26 changes: 23 additions & 3 deletions packages/app-mobile/components/side-menu-content.tsx
Expand Up @@ -16,6 +16,7 @@ import { reg } from '@joplin/lib/registry';
import { ProfileConfig } from '@joplin/lib/services/profileConfig/types';
import { getTrashFolderIcon, getTrashFolderId } from '@joplin/lib/services/trash';
import restoreItems from '@joplin/lib/services/trash/restoreItems';
import emptyTrash from '@joplin/lib/services/trash/emptyTrash';
import { ModelType } from '@joplin/lib/BaseModel';
const { substrWithEllipsis } = require('@joplin/lib/string-utils');

Expand Down Expand Up @@ -146,11 +147,30 @@ const SideMenuContentComponent = (props: Props) => {

const folder = folderOrAll as FolderEntity;

if (folder && folder.id === getTrashFolderId()) return;

const menuItems: any[] = [];

if (folder && !!folder.deleted_time) {
if (folder && folder.id === getTrashFolderId()) {
menuItems.push({
text: _('Empty trash'),
onPress: async () => {
Alert.alert('', _('This will permanently delete all items in the trash. Continue?'), [
{
text: _('Empty trash'),
onPress: async () => {
await emptyTrash();
},
},
{
text: _('Cancel'),
onPress: () => { },
style: 'cancel',
},
]);
},
style: 'destructive',
});

} else if (folder && !!folder.deleted_time) {
menuItems.push({
text: _('Restore'),
onPress: async () => {
Expand Down