1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Electron: Resolves #612: Allow duplicating a note

This commit is contained in:
Laurent Cozic
2018-06-27 21:45:31 +01:00
parent 7d7e1e1637
commit 310afb0ad6
8 changed files with 33 additions and 18 deletions

View File

@ -420,6 +420,7 @@ class Note extends BaseItem {
static async duplicate(noteId, options = null) {
const changes = options && options.changes;
const uniqueTitle = options && options.uniqueTitle;
const originalNote = await Note.load(noteId);
if (!originalNote) throw new Error('Unknown note: ' + noteId);
@ -432,6 +433,11 @@ class Note extends BaseItem {
newNote[n] = changes[n];
}
if (uniqueTitle) {
const title = await Note.findUniqueItemTitle(uniqueTitle);
newNote.title = title;
}
return this.save(newNote);
}