mirror of
https://github.com/laurent22/joplin.git
synced 2025-03-29 21:21:15 +02:00
All: Do no duplicate resources when duplicating a note
This commit is contained in:
parent
ab5d799f3d
commit
721d00874f
packages/lib/models
@ -153,7 +153,7 @@ describe('models/Note', function() {
|
|||||||
const resource = (await Resource.all())[0];
|
const resource = (await Resource.all())[0];
|
||||||
expect((await Resource.all()).length).toBe(1);
|
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();
|
const resources: ResourceEntity[] = await Resource.all();
|
||||||
expect(resources.length).toBe(2);
|
expect(resources.length).toBe(2);
|
||||||
|
@ -611,6 +611,7 @@ export default class Note extends BaseItem {
|
|||||||
public static async duplicate(noteId: string, options: any = null) {
|
public static async duplicate(noteId: string, options: any = null) {
|
||||||
const changes = options && options.changes;
|
const changes = options && options.changes;
|
||||||
const uniqueTitle = options && options.uniqueTitle;
|
const uniqueTitle = options && options.uniqueTitle;
|
||||||
|
const duplicateResources = options && !!options.duplicateResources;
|
||||||
|
|
||||||
const originalNote: NoteEntity = await Note.load(noteId);
|
const originalNote: NoteEntity = await Note.load(noteId);
|
||||||
if (!originalNote) throw new Error(`Unknown note: ${noteId}`);
|
if (!originalNote) throw new Error(`Unknown note: ${noteId}`);
|
||||||
@ -632,7 +633,7 @@ export default class Note extends BaseItem {
|
|||||||
newNote.title = title;
|
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 newNoteSaved = await this.save(newNote);
|
||||||
const originalTags = await Tag.tagsByNoteId(noteId);
|
const originalTags = await Tag.tagsByNoteId(noteId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user