fix(livewire): resolve Echo not found error due to lazy loading timing

This commit is contained in:
idevakk
2026-03-05 15:54:50 +05:30
parent bfc2662efb
commit 62d8f15919
2 changed files with 4 additions and 7 deletions

View File

@@ -3,9 +3,7 @@ import Echo from 'laravel-echo';
import Pusher from 'pusher-js';
window.Pusher = Pusher;
window.startReverb = function () {
if (window.Echo) return window.Echo;
if (document.querySelector('[data-requires-reverb]')) {
window.Echo = new Echo({
broadcaster: 'reverb',
key: import.meta.env.VITE_REVERB_APP_KEY,
@@ -15,6 +13,4 @@ window.startReverb = function () {
forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
});
return window.Echo;
};
}

View File

@@ -1,4 +1,5 @@
<div class="flex h-full bg-zinc-950 overflow-hidden relative"
data-requires-reverb="true"
x-data="{
sidebarOpen: window.innerWidth >= 1280,
selectedId: @entangle('selectedEmailId'),
@@ -20,7 +21,7 @@
});
}
}"
x-init="window.startReverb(); $watch('selectedId', value => { if(value && window.innerWidth < 1024) mobileView = 'detail' }); $watch('mobileView', value => { if(value === 'list' && window.innerWidth < 1024) selectedId = null })"
x-init="$watch('selectedId', value => { if(value && window.innerWidth < 1024) mobileView = 'detail' }); $watch('mobileView', value => { if(value === 'list' && window.innerWidth < 1024) selectedId = null })"
@resize.window="if (window.innerWidth >= 1280) sidebarOpen = true">
<!-- Global Confirmation Modal -->