Вход Регистрация
Файл: upload/core/js/undear_dialog.js
Строк: 29
<?php
let activePeer 
window.msgActivePeer || 0;

function 
updateUnreadDialogs() {

    
fetch(`/core/ajax/messages/unread_dialogs.php?user=${window.msgUserId}`)
        .
then(=> r.json())
        .
then(data => {

            
// Скрываем все бейджи
            
document.querySelectorAll('.chat-unread-badge').forEach(el => {
                
el.style.display 'none';
            });

            
// Обновляем только те, где есть непрочитанные
            
for (const peerId in data) {

                
// Не показываем непрочитанные в активном чате
                
if (parseInt(peerId) === activePeer) continue;

                const 
badge document.querySelector(`.chat-unread-badge[data-peer="${peerId}"]`);
                if (
badge) {
                    
badge.textContent data[peerId];
                    
badge.style.display 'inline-block';
                }
            }
        })
        .finally(() => {
            
// Запускаем следующий цикл только после завершения запроса
            
setTimeout(updateUnreadDialogs2000);
        });
}

// Первый запуск
updateUnreadDialogs();
?>
Онлайн: 0
Реклама