Fix notifications hook registration
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user