Files
jabali-panel/resources/views/filament/partials/notifications-refresh.blade.php
2026-01-31 03:10:02 +02:00

36 lines
1.0 KiB
PHP

<script data-navigate-once>
(function () {
let hookRegistered = false;
const registerHook = () => {
if (hookRegistered || !window.Livewire?.hook || !window.Livewire?.dispatch) {
return;
}
hookRegistered = true;
window.Livewire.hook('commit', ({ component, succeed }) => {
if (component?.name === 'notifications') {
return;
}
succeed(() => {
if (window.Livewire?.dispatchTo) {
window.Livewire.dispatchTo('notifications', 'notificationsSent');
return;
}
window.Livewire.dispatch('notificationsSent');
});
});
};
document.addEventListener('livewire:init', registerHook);
document.addEventListener('livewire:navigated', registerHook);
if (window.Livewire?.hook) {
registerHook();
}
})();
</script>