Fix create draft issue duplicate id (#2935)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2023-04-11 17:07:44 +07:00
committed by GitHub
parent 9c79f20aa4
commit 2b72b64df5
7 changed files with 49 additions and 45 deletions
@@ -144,7 +144,7 @@
}
}
async function saveAttachment (doc: Attachment): Promise<void> {
async function saveAttachment (doc: Attachment, objectId: Ref<Doc> | undefined): Promise<void> {
if (space === undefined || objectId === undefined || _class === undefined) return
await client.addCollection(attachment.class.Attachment, space, objectId, _class, 'attachments', doc, doc._id)
}
@@ -218,7 +218,7 @@
}
}
export async function createAttachments (): Promise<void> {
export async function createAttachments (_id: Ref<Doc> | undefined = objectId): Promise<void> {
if (saved) {
return
}
@@ -227,7 +227,7 @@
newAttachments.forEach((p) => {
const attachment = attachments.get(p)
if (attachment !== undefined) {
promises.push(saveAttachment(attachment))
promises.push(saveAttachment(attachment, _id))
}
})
removedAttachments.forEach((p) => {