From 721d00874f9860f276483b7097024dbdc74f5fad Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 21 Dec 2021 11:03:55 +0100 Subject: [PATCH] All: Do no duplicate resources when duplicating a note --- packages/lib/models/Note.test.ts | 2 +- packages/lib/models/Note.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/lib/models/Note.test.ts b/packages/lib/models/Note.test.ts index c6b5f693a4..7a57a0c8a6 100644 --- a/packages/lib/models/Note.test.ts +++ b/packages/lib/models/Note.test.ts @@ -153,7 +153,7 @@ describe('models/Note', function() { const resource = (await Resource.all())[0]; expect((await Resource.all()).length).toBe(1); - const duplicatedNote = await Note.duplicate(note.id); + const duplicatedNote = await Note.duplicate(note.id, { duplicateResources: true }); const resources: ResourceEntity[] = await Resource.all(); expect(resources.length).toBe(2); diff --git a/packages/lib/models/Note.ts b/packages/lib/models/Note.ts index e70e553f22..b8a6eaf466 100644 --- a/packages/lib/models/Note.ts +++ b/packages/lib/models/Note.ts @@ -611,6 +611,7 @@ export default class Note extends BaseItem { public static async duplicate(noteId: string, options: any = null) { const changes = options && options.changes; const uniqueTitle = options && options.uniqueTitle; + const duplicateResources = options && !!options.duplicateResources; const originalNote: NoteEntity = await Note.load(noteId); if (!originalNote) throw new Error(`Unknown note: ${noteId}`); @@ -632,7 +633,7 @@ export default class Note extends BaseItem { newNote.title = title; } - newNote.body = await this.duplicateNoteResources(newNote.body); + if (duplicateResources) newNote.body = await this.duplicateNoteResources(newNote.body); const newNoteSaved = await this.save(newNote); const originalTags = await Tag.tagsByNoteId(noteId);