42 lines
1.3 KiB
PHP
42 lines
1.3 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(() => {
|
|
const dispatchTo = window.Livewire?.dispatchTo;
|
|
if (dispatchTo) {
|
|
['notifications', 'filament.notifications', 'filament-notifications'].forEach((name) => {
|
|
try {
|
|
dispatchTo(name, 'notificationsSent');
|
|
} catch (error) {
|
|
// ignore missing component names
|
|
}
|
|
});
|
|
}
|
|
|
|
window.Livewire?.dispatch?.('notificationsSent');
|
|
});
|
|
});
|
|
};
|
|
|
|
document.addEventListener('livewire:init', registerHook);
|
|
document.addEventListener('livewire:navigated', registerHook);
|
|
|
|
if (window.Livewire?.hook) {
|
|
registerHook();
|
|
}
|
|
})();
|
|
</script>
|