All: Do no duplicate resources when duplicating a note

backoff_plugin
Laurent Cozic 2021-12-21 11:03:55 +01:00
parent ab5d799f3d
commit 721d00874f
2 changed files with 3 additions and 2 deletions

View File

@ -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);

View File

@ -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);