Buddy list: per-person outline with online/away/offline status dots
This commit is contained in:
parent
859a8f67da
commit
4e2676433f
3 changed files with 53 additions and 4 deletions
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Web OSCAR Chat</title>
|
||||
<link rel="stylesheet" href="/style.css?v=24">
|
||||
<link rel="stylesheet" href="/style.css?v=25">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
|
|
@ -86,6 +86,6 @@
|
|||
</main>
|
||||
</div>
|
||||
|
||||
<script type="module" src="/app.js?v=24"></script>
|
||||
<script type="module" src="/app.js?v=25"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -146,6 +146,16 @@ 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 (['offline', 'disconnected'].includes(raw)) 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';
|
||||
}
|
||||
|
||||
export function renderBuddies(buddies, onOpen) {
|
||||
const list = el('buddies');
|
||||
clear(list);
|
||||
|
|
@ -154,8 +164,24 @@ export function renderBuddies(buddies, onOpen) {
|
|||
const name = typeof b === 'string'
|
||||
? b
|
||||
: (b.aimId || b.displayId || b.screenName || b.name || JSON.stringify(b));
|
||||
const state = b && typeof b === 'object' && b.state ? ` (${b.state})` : '';
|
||||
li.appendChild(button(`${name}${state}`, () => onOpen(name)));
|
||||
const status = typeof b === 'string' ? 'offline' : buddyStatus(b);
|
||||
const statusMsg = b?.statusMsg || b?.awayMsg || b?.statusMessage || '';
|
||||
const title = statusMsg ? `${status}: ${statusMsg}` : status;
|
||||
|
||||
const btn = document.createElement('button');
|
||||
btn.type = 'button';
|
||||
btn.className = 'buddy-item';
|
||||
btn.title = title;
|
||||
btn.addEventListener('click', () => onOpen(name));
|
||||
|
||||
const dot = document.createElement('span');
|
||||
dot.className = `status-dot status-${status}`;
|
||||
const label = document.createElement('span');
|
||||
label.className = 'buddy-name';
|
||||
label.textContent = name;
|
||||
|
||||
btn.append(dot, label);
|
||||
li.appendChild(btn);
|
||||
list.appendChild(li);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,3 +273,26 @@ main { padding: 1rem; max-width: 1600px; margin: 0 auto; }
|
|||
0%, 100% { box-shadow: 0 0 0 rgba(255, 209, 102, 0); border-color: rgba(255, 209, 102, 0.35); }
|
||||
50% { box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.12), 0 0 18px rgba(255, 209, 102, 0.18); border-color: rgba(255, 209, 102, 0.9); }
|
||||
}
|
||||
|
||||
.buddy-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
background: rgba(255,255,255,0.02);
|
||||
color: var(--text);
|
||||
border: 1px solid var(--border);
|
||||
padding: 0.45rem 0.55rem;
|
||||
}
|
||||
.buddy-item:hover { background: var(--accent-soft); border-color: rgba(77,163,255,0.3); }
|
||||
.status-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
flex: 0 0 10px;
|
||||
}
|
||||
.status-online { background: #2ecc71; box-shadow: 0 0 0 2px rgba(46,204,113,0.15); }
|
||||
.status-away { background: #f1c40f; box-shadow: 0 0 0 2px rgba(241,196,15,0.15); }
|
||||
.status-offline { background: #e74c3c; box-shadow: 0 0 0 2px rgba(231,76,60,0.15); }
|
||||
.buddy-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue