Fix notifications hook registration

This commit is contained in:
root
2026-01-31 03:06:53 +02:00
parent 4d529a2e52
commit 99f9dacba9

View File

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