mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { CommandRuntime, CommandDeclaration, CommandContext } from '../services/CommandService';
|
|
import { _ } from '../locale';
|
|
import Note from '../models/Note';
|
|
import shim from '../shim';
|
|
|
|
export const declaration: CommandDeclaration = {
|
|
name: 'permanentlyDeleteNote',
|
|
label: () => _('Permanently delete note'),
|
|
iconName: 'fa-times',
|
|
};
|
|
|
|
export const runtime = (): CommandRuntime => {
|
|
return {
|
|
execute: async (context: CommandContext, noteIds: string[] = null) => {
|
|
if (noteIds === null) noteIds = context.state.selectedNoteIds;
|
|
if (!noteIds.length) return;
|
|
const msg = await Note.permanentlyDeleteMessage(noteIds);
|
|
|
|
const deleteIndex = 0;
|
|
const result = await shim.showMessageBox(msg, {
|
|
buttons: [_('Delete'), _('Cancel')],
|
|
defaultId: 1,
|
|
cancelId: 1,
|
|
type: 'question',
|
|
});
|
|
|
|
if (result === deleteIndex) {
|
|
await Note.batchDelete(noteIds, { toTrash: false, sourceDescription: 'permanentlyDeleteNote command' });
|
|
}
|
|
},
|
|
enabledCondition: '(!noteIsReadOnly || inTrash) && someNotesSelected',
|
|
};
|
|
};
|