@@ -64,7 +64,7 @@ async function createAttachment (currentUser, challengeId, attachment) {
64
64
// update challenge object
65
65
await challengeService . partiallyUpdateChallenge ( currentUser , challengeId , {
66
66
attachments : [
67
- ...challenge . attachments ,
67
+ ..._ . get ( challenge , ' attachments' , [ ] ) ,
68
68
ret
69
69
]
70
70
} )
@@ -123,7 +123,7 @@ async function update (currentUser, challengeId, attachmentId, data, isFull) {
123
123
124
124
const ret = await helper . update ( attachment , data )
125
125
// update challenge object
126
- const newAttachments = challenge . attachments
126
+ const newAttachments = _ . get ( challenge , ' attachments' , [ ] )
127
127
try {
128
128
newAttachments [ _ . findIndex ( newAttachments , a => a . id === attachmentId ) ] = ret
129
129
await challengeService . partiallyUpdateChallenge ( currentUser , challengeId , {
@@ -198,7 +198,7 @@ async function deleteAttachment (currentUser, challengeId, attachmentId) {
198
198
}
199
199
await attachment . delete ( )
200
200
// update challenge object
201
- const newAttachments = challenge . attachments
201
+ const newAttachments = _ . get ( challenge , ' attachments' , [ ] )
202
202
try {
203
203
newAttachments . splice ( _ . findIndex ( newAttachments , a => a . id === attachmentId ) , 1 )
204
204
await challengeService . partiallyUpdateChallenge ( currentUser , challengeId , {
0 commit comments