Skip to content

Commit

Permalink
Merge pull request #1224 from NicoPennec/fix/upload-previews
Browse files Browse the repository at this point in the history
Fix upload multi previews
  • Loading branch information
NicoPennec authored Oct 20, 2023
2 parents d5e3507 + 9338ed6 commit bbaa40e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/store/modules/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,11 @@ const actions = {
},

commentTaskWithPreview(
{ commit, getters, state, dispatch },
{ commit, state },
{ taskId, comment, revision, taskStatusId, form, attachment, checklist }
) {
const data = { taskId, taskStatusId, comment, attachment, checklist }
const remainingPreviews = [...state.previewForms].splice(1)
commit(ADD_PREVIEW_START)
let newComment
locks[taskId] = true
Expand Down Expand Up @@ -580,23 +581,21 @@ const actions = {
commentId: newComment.id,
comment: newComment
})
return Promise.resolve(preview)
return preview
})
}
const remainingPreviews = [...state.previewForms].splice(1)
// run promise in sequence
return remainingPreviews.reduce((accumulatorPromise, form) => {
return accumulatorPromise.then(() => {
return addPreview(form)
})
return accumulatorPromise.then(() => addPreview(form))
}, Promise.resolve())
} else {
return Promise.resolve(preview)
return preview
}
})
.then(preview => {
commit(NEW_TASK_COMMENT_END, { comment: newComment, taskId })
commit(CLEAR_UPLOAD_PROGRESS)
return Promise.resolve({ newComment, preview })
return { newComment, preview }
})
)
},
Expand Down

0 comments on commit bbaa40e

Please sign in to comment.