diff --git a/internal/web/static/index.html b/internal/web/static/index.html index 9cee8ff..e015af3 100644 --- a/internal/web/static/index.html +++ b/internal/web/static/index.html @@ -2397,10 +2397,11 @@ var refreshingChannels = {}; // tracks channels with an in-flight refresh // ===== MOBILE NAV ===== + var mobileQuery = window.matchMedia('(max-width: 768px)'); var chatIsOpen = false; function openChat() { chatIsOpen = true; - if (window.innerWidth <= 768) { + if (mobileQuery.matches) { document.getElementById('app').classList.add('chat-open'); history.pushState({ view: 'chat' }, ''); } @@ -2410,10 +2411,15 @@ document.getElementById('app').classList.remove('chat-open'); } window.addEventListener('popstate', function () { - if (window.innerWidth <= 768 && document.getElementById('app').classList.contains('chat-open')) { + if (mobileQuery.matches && document.getElementById('app').classList.contains('chat-open')) { openSidebar(); } }); + document.addEventListener('visibilitychange', function () { + if (!document.hidden && mobileQuery.matches && chatIsOpen) { + document.getElementById('app').classList.add('chat-open'); + } + }); function filterChannels() { var q = document.getElementById('channelSearch').value.toLowerCase(); document.querySelectorAll('.ch-item').forEach(function (el) { el.style.display = el.dataset.name.toLowerCase().includes(q) ? 'flex' : 'none' }); @@ -3593,7 +3599,7 @@ document.getElementById('progressPanel').innerHTML = ''; var p = document.getElementById('progressPanel'); p.innerHTML = '