Skip to content

Commit

Permalink
[5.x] Fix toasts in actions not being shown (#10828)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga authored Sep 23, 2024
1 parent 5db2012 commit 1a1aa56
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions resources/js/components/ToastBus.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@ class ToastBus {

intercept() {
this.instance.$axios.interceptors.response.use(response => {
const toasts = response?.data?._toasts ?? []
const data = response?.data;

toasts.forEach(toast => this.instance.$toast[toast.type](toast.message, {duration: toast.duration}))
if (!data) return response;

const promise = data instanceof Blob
? data.text().then(text => JSON.parse(text))
: new Promise(resolve => resolve(data));

promise.then(json => {
const toasts = json._toasts ?? [];
toasts.forEach(toast => this.instance.$toast[toast.type](toast.message, {duration: toast.duration}))
});

return response;
});
Expand Down

0 comments on commit 1a1aa56

Please sign in to comment.