diff --git a/public/index.html b/public/index.html index d787e8c..d7e129e 100644 --- a/public/index.html +++ b/public/index.html @@ -34,15 +34,15 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/public/js/app.js b/public/js/app.js index de4ea41..c810412 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -556,6 +556,22 @@ function escapeHtml(s) { return String(s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); } +function formatTime(s) { + if (!s) return ''; + try { + const d = new Date(s); + if (isNaN(d.getTime())) return ''; + const now = new Date(); + const sameDay = d.toDateString() === now.toDateString(); + const hh = String(d.getHours()).padStart(2, '0'); + const mm = String(d.getMinutes()).padStart(2, '0'); + if (sameDay) return `${hh}:${mm}`; + const dd = String(d.getDate()).padStart(2, '0'); + const mo = String(d.getMonth() + 1).padStart(2, '0'); + return `${dd}.${mo} ${hh}:${mm}`; + } catch { return ''; } +} + // Debug-оверлей: показывает ошибки JS прямо на экране (для отладки в обычном браузере) window.addEventListener('error', (e) => { console.error('Global error:', e); diff --git a/public/js/views/chat.js b/public/js/views/chat.js index 5c6583d..4ddcb60 100644 --- a/public/js/views/chat.js +++ b/public/js/views/chat.js @@ -83,6 +83,7 @@ const ChatView = { appendMessage(m) { console.log('[Chat] appendMessage called, m:', JSON.stringify(m).slice(0, 200), 'me check:', API.Store.user && m.sender_id === (API.Store.user.id || API.Store.user.user_id)); + try { const box = document.getElementById('messages'); if (!box) { console.error('[Chat] appendMessage: no box'); return; } const me = API.Store.user && m.sender_id === (API.Store.user.id || API.Store.user.user_id); @@ -110,6 +111,12 @@ const ChatView = { box.appendChild(div); console.log('[Chat] appended bubble, children:', box.children.length); box.scrollTop = box.scrollHeight; + } catch (e) { + console.error('[Chat] appendMessage EXCEPTION:', e, 'm:', JSON.stringify(m).slice(0, 200)); + try { + fetch('/api/v1/debug/log', { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ kind: 'AppendMsgError', msg: String(e && e.message), stack: String(e && e.stack || '').slice(0, 400), m: String(JSON.stringify(m).slice(0, 200)) }) }); + } catch {} + } }, onMessageClick(m) {