{{-- resources/views/livewire/wire-chat/typing-indicator.blade.php --}} @php // Defensive programming - ensure variables exist $typingUsers = $typingUsers ?? []; $showAvatars = $showAvatars ?? true; $conversationId = $conversationId ?? 'unknown'; @endphp {{-- Reduced polling frequency to avoid too many requests --}}
{{-- Debug information --}} {{-- @if(config('app.debug'))
Debug Info:
Cache Driver: {{ config('cache.default') }}
Conversation ID: {{ $conversationId }}
Current User: {{ $currentUserId ?? 'null' }} ({{ $currentUserName ?? 'null' }})
Current User Type: {{ $currentUserType ?? 'null' }}
Typing Users: {{ is_array($typingUsers) ? count($typingUsers) : 'not-array' }} @if(is_array($typingUsers) && count($typingUsers) > 0) @foreach($typingUsers as $user)
- {{ $user['user_name'] ?? 'Unknown' }} (ID: {{ $user['user_id'] ?? 'Unknown' }}) @endforeach @endif
@endif --}} @if(is_array($typingUsers) && count($typingUsers) > 0)
@if($showAvatars && count($typingUsers) <= 3)
@foreach($typingUsers as $index => $user) @php $userName = $user['user_name'] ?? 'User'; $userAvatar = Storage::url($user['avatar']) ?? null; @endphp @if($userAvatar) {{ $userName }} @else
{{ substr($userName, 0, 1) }}
@endif @endforeach
@endif
@php $count = count($typingUsers); if ($count === 1) { $text = ($typingUsers[0]['user_name'] ?? __('Someone')) . ' ' . __('is typing...'); } elseif ($count === 2) { $name1 = $typingUsers[0]['user_name'] ?? __('Someone'); $name2 = $typingUsers[1]['user_name'] ?? __('Someone'); $text = $name1 . ' and ' . $name2 . ' ' . __('are typing...'); } else { $name1 = $typingUsers[0]['user_name'] ?? __('Someone'); $text = $name1 . ' and ' . ($count - 1) . ' ' . __('others are typing...'); } echo $text; @endphp
@else {{-- Show when no one is typing (for debugging) --}} {{-- @if(config('app.debug'))
No one typing... Polling every 2 seconds for updates.
@endif --}} @endif
@push('scripts') @endpush