1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/packages/app-desktop/gui/WindowCommandsAndDialogs/commands/restoreNote.ts
Henry Heino 4a88d6ff7a
Desktop: Multiple window support (#11181)
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
2024-11-08 15:32:05 +00:00

24 lines
915 B
TypeScript

import { CommandRuntime, CommandDeclaration, CommandContext } from '@joplin/lib/services/CommandService';
import { _ } from '@joplin/lib/locale';
import Note from '@joplin/lib/models/Note';
import restoreItems from '@joplin/lib/services/trash/restoreItems';
import { NoteEntity } from '@joplin/lib/services/database/types';
import { ModelType } from '@joplin/lib/BaseModel';
export const declaration: CommandDeclaration = {
name: 'restoreNote',
label: () => _('Restore note'),
iconName: 'fas fa-trash-restore',
};
export const runtime = (): CommandRuntime => {
return {
execute: async (context: CommandContext, noteIds: string[] = null) => {
if (noteIds === null) noteIds = context.state.selectedNoteIds;
const notes: NoteEntity[] = await Note.byIds(noteIds, { fields: ['id', 'parent_id'] });
await restoreItems(ModelType.Note, notes);
},
enabledCondition: 'allSelectedNotesAreDeleted',
};
};