Skip to content

Commit dc63bf8

Browse files
Fix issue in attachment service with missing attachments on challenges
1 parent b4b1a2c commit dc63bf8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/services/AttachmentService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async function createAttachment (currentUser, challengeId, attachment) {
6464
// update challenge object
6565
await challengeService.partiallyUpdateChallenge(currentUser, challengeId, {
6666
attachments: [
67-
...challenge.attachments,
67+
..._.get(challenge, 'attachments', []),
6868
ret
6969
]
7070
})
@@ -123,7 +123,7 @@ async function update (currentUser, challengeId, attachmentId, data, isFull) {
123123

124124
const ret = await helper.update(attachment, data)
125125
// update challenge object
126-
const newAttachments = challenge.attachments
126+
const newAttachments = _.get(challenge, 'attachments', [])
127127
try {
128128
newAttachments[_.findIndex(newAttachments, a => a.id === attachmentId)] = ret
129129
await challengeService.partiallyUpdateChallenge(currentUser, challengeId, {
@@ -198,7 +198,7 @@ async function deleteAttachment (currentUser, challengeId, attachmentId) {
198198
}
199199
await attachment.delete()
200200
// update challenge object
201-
const newAttachments = challenge.attachments
201+
const newAttachments = _.get(challenge, 'attachments', [])
202202
try {
203203
newAttachments.splice(_.findIndex(newAttachments, a => a.id === attachmentId), 1)
204204
await challengeService.partiallyUpdateChallenge(currentUser, challengeId, {

0 commit comments

Comments
 (0)