diff --git a/public/app.js b/public/app.js index 46eb87e..dd78365 100644 --- a/public/app.js +++ b/public/app.js @@ -243,6 +243,23 @@ stream.on('buddylist', (event) => { ui.renderBuddies(state.buddies, (name) => openIM(name)); }); +stream.on('presence', (event) => { + const d = event.data || event.raw?.eventData || {}; + const name = String(d.screenName || d.aimId || d.displayId || d.name || ''); + if (!name) return; + const norm = normalizeName(name); + let found = false; + state.buddies = (state.buddies || []).map((b) => { + const bName = typeof b === 'string' ? b : (b.aimId || b.displayId || b.screenName || b.name || ''); + if (normalizeName(bName) !== norm) return b; + found = true; + const base = typeof b === 'string' ? { screenName: b } : { ...b }; + return { ...base, ...d, screenName: base.screenName || name }; + }); + if (!found) state.buddies.push({ screenName: name, ...d }); + ui.renderBuddies(state.buddies, (n) => openIM(n)); +}); + stream.on('broadcast', (event) => { const d = event.data || event.raw?.eventData || {}; const text = event.text || d.message || d.text || d.msg || ''; diff --git a/public/index.html b/public/index.html index 0602752..9bb7e6e 100644 --- a/public/index.html +++ b/public/index.html @@ -4,7 +4,7 @@ Web OSCAR Chat - +
@@ -86,6 +86,6 @@
- + diff --git a/public/js/ui.js b/public/js/ui.js index b8295a8..daf19d8 100644 --- a/public/js/ui.js +++ b/public/js/ui.js @@ -149,8 +149,10 @@ export function renderUserResults(users, onOpen) { function buddyStatus(b) { const raw = String(b?.state || b?.status || '').toLowerCase(); if (['online', 'present', 'active'].includes(raw)) return 'online'; - if (['away', 'idle', 'dnd', 'busy', 'na'].includes(raw) || b?.idleMins > 0) return 'away'; + if (['away', 'idle', 'dnd', 'busy', 'na'].includes(raw) || Number(b?.idleMins) > 0) return 'away'; if (['offline', 'disconnected'].includes(raw)) return 'offline'; + if (b?.online === true || b?.online === 'true' || b?.online === 1) return 'online'; + if (b?.online === false || b?.online === 'false' || b?.online === 0) return 'offline'; // If we have an object but no explicit state, default to offline/unknown. if (b && typeof b === 'object' && !raw) return 'offline'; return raw ? 'away' : 'offline';