36 lines
1.0 KiB
PHP
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>
|