Skip to content

Commit

Permalink
Make sure action response is always processed (#23)
Browse files Browse the repository at this point in the history
* Make sure action response is always processed

Not sure what the offending cause is doing, and if it works for other people, so I wrapped it in a try/catch block.

* Update field.js
  • Loading branch information
infostreams authored Apr 20, 2021
1 parent 0d5bf49 commit 2d3ef22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions resources/js/components/DetailField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,17 @@ export default {
* Handle the action response. Typically either a message, download or a redirect.
*/
handleActionResponse(data) {
this.$parent.$parent.$children[2].$emit('actionExecuted')
try {
this.$parent.$parent.$children[2].$emit('actionExecuted')
} catch (e) {
// Somehow didn't work. We continue so that the response is processed anyway.
}
if (data.message) {
this.$parent.$parent.$children[2].$emit('actionExecuted')
Nova.$emit('action-executed')
Nova.success(data.message)
} else if (data.deleted) {
this.$parent.$parent.$children[2].$emit('actionExecuted')
Nova.$emit('action-executed')
} else if (data.danger) {
this.$parent.$parent.$children[2].$emit('actionExecuted')
Nova.$emit('action-executed')
Nova.error(data.danger)
} else if (data.download) {
Expand All @@ -148,7 +149,6 @@ export default {
} else if (data.openInNewTab) {
window.open(data.openInNewTab, '_blank')
} else {
this.$parent.$parent.$children[2].$emit('actionExecuted')
Nova.$emit('action-executed')
Nova.success(this.__('The action ran successfully!'))
}
Expand Down

0 comments on commit 2d3ef22

Please sign in to comment.