Force notifications refresh after Livewire commits

This commit is contained in:
root
2026-01-31 03:22:18 +02:00
parent 267170fe11
commit fac98a3c61

View File

@@ -15,7 +15,23 @@
} }
succeed(() => { 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) { if (dispatchTo) {
['notifications', 'filament.notifications', 'filament-notifications'].forEach((name) => { ['notifications', 'filament.notifications', 'filament-notifications'].forEach((name) => {
try { try {
@@ -26,7 +42,7 @@
}); });
} }
window.Livewire?.dispatch?.('notificationsSent'); livewire?.dispatch?.('notificationsSent');
}); });
}); });
}; };