Force notifications refresh after Livewire commits
This commit is contained in:
@@ -15,7 +15,23 @@
|
||||
}
|
||||
|
||||
succeed(() => {
|
||||
const dispatchTo = window.Livewire?.dispatchTo;
|
||||
const livewire = window.Livewire;
|
||||
const allComponents = typeof livewire?.all === 'function' ? livewire.all() : [];
|
||||
const notificationsComponent = allComponents.find((component) => {
|
||||
const name = component?.name ?? '';
|
||||
return name === 'notifications' || name.includes('notifications');
|
||||
});
|
||||
|
||||
if (notificationsComponent?.$wire?.pullNotificationsFromSession) {
|
||||
try {
|
||||
notificationsComponent.$wire.pullNotificationsFromSession();
|
||||
return;
|
||||
} catch (error) {
|
||||
// fall back to dispatch-based refresh
|
||||
}
|
||||
}
|
||||
|
||||
const dispatchTo = livewire?.dispatchTo;
|
||||
if (dispatchTo) {
|
||||
['notifications', 'filament.notifications', 'filament-notifications'].forEach((name) => {
|
||||
try {
|
||||
@@ -26,7 +42,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
window.Livewire?.dispatch?.('notificationsSent');
|
||||
livewire?.dispatch?.('notificationsSent');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user