diff --git a/resources/views/filament/partials/notifications-refresh.blade.php b/resources/views/filament/partials/notifications-refresh.blade.php index b1059e1..8c1db4b 100644 --- a/resources/views/filament/partials/notifications-refresh.blade.php +++ b/resources/views/filament/partials/notifications-refresh.blade.php @@ -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'); }); }); };