{{-- «Вас вызвали на дуэль» — on every page, for a student or teacher with a challenge waiting (Duels::pendingCountForUser()). The menu badge alone was easy to miss. Live: the script below polls /duel_invites.php (DuelController::invites) every POLL_MS while the tab is visible, and straight away when the tab comes back, so a challenge shows up without a reload. It also keeps the «Игры» menu badges ([data-duel-badge]) in step. On /games.php (its «Дуэли» list has the challenge already) and on a game page mid-duel (?duel=) the banner isn't rendered on load — it only appears there for a challenge that arrives after the page was opened. The × hides the banner for that one challenge (sessionStorage), not for the next. --}} @php $duelLive = in_array($role, ['student', 'teacher'], true) && \App\Support\Modules::enabled('games'); $duelInvite = null; $duelInviteCount = 0; $duelQuietOnLoad = request()->is('games.php') || request()->has('duel'); if ($duelLive) { $duelInviteCount = \App\Services\Duels::pendingCountForUser(\App\Support\SessionAuth::id()); if ($duelInviteCount > 0 && ($playerId = \App\Services\Duels::currentPlayerId()) !== null) { $duelInvite = \App\Services\Duels::latestIncoming($playerId); } } $duelShow = $duelInvite !== null && ! $duelQuietOnLoad; // A live group game (App\Services\GroupGames) for a student — announced // by the same poll; not on the game's own page. $groupInvite = null; if ($duelLive && $role === 'student' && ! request()->has('group_game') && ($groupStudentId = \App\Services\GroupGames::currentStudentId()) !== null) { $groupInvite = \App\Services\GroupGames::inviteFor($groupStudentId); } @endphp @if ($duelLive && $role === 'student') @endif @if ($duelLive) @endif