Buddy status: only online/offline dots
This commit is contained in:
parent
25efc314e8
commit
b7ba76cc13
2 changed files with 6 additions and 9 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Web OSCAR Chat</title>
|
<title>Web OSCAR Chat</title>
|
||||||
<link rel="stylesheet" href="/style.css?v=28">
|
<link rel="stylesheet" href="/style.css?v=29">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
|
|
@ -98,6 +98,6 @@
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="module" src="/app.js?v=28"></script>
|
<script type="module" src="/app.js?v=29"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -148,14 +148,12 @@ export function renderUserResults(users, onOpen) {
|
||||||
|
|
||||||
function buddyStatus(b) {
|
function buddyStatus(b) {
|
||||||
const raw = String(b?.state || b?.status || '').toLowerCase();
|
const raw = String(b?.state || b?.status || '').toLowerCase();
|
||||||
if (['online', 'present', 'active'].includes(raw)) return 'online';
|
|
||||||
if (['away', 'idle', 'dnd', 'busy', 'na'].includes(raw) || Number(b?.idleMins) > 0) return 'away';
|
|
||||||
if (['offline', 'disconnected'].includes(raw)) return 'offline';
|
if (['offline', 'disconnected'].includes(raw)) return 'offline';
|
||||||
|
if (['online', 'present', 'active', 'away', 'idle', 'dnd', 'busy', 'na'].includes(raw)) return 'online';
|
||||||
if (b?.online === true || b?.online === 'true' || b?.online === 1) return 'online';
|
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 (b?.online === false || b?.online === 'false' || b?.online === 0) return 'offline';
|
||||||
// If we have an object but no explicit state, default to offline/unknown.
|
// Only online/offline supported; unknown defaults to offline.
|
||||||
if (b && typeof b === 'object' && !raw) return 'offline';
|
return 'offline';
|
||||||
return raw ? 'away' : 'offline';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderBuddies(buddies, onOpen) {
|
export function renderBuddies(buddies, onOpen) {
|
||||||
|
|
@ -167,8 +165,7 @@ export function renderBuddies(buddies, onOpen) {
|
||||||
? b
|
? b
|
||||||
: (b.aimId || b.displayId || b.screenName || b.name || JSON.stringify(b));
|
: (b.aimId || b.displayId || b.screenName || b.name || JSON.stringify(b));
|
||||||
const status = typeof b === 'string' ? 'offline' : buddyStatus(b);
|
const status = typeof b === 'string' ? 'offline' : buddyStatus(b);
|
||||||
const statusMsg = b?.statusMsg || b?.awayMsg || b?.statusMessage || '';
|
const title = status === 'online' ? 'Online' : 'Offline';
|
||||||
const title = statusMsg ? `${status}: ${statusMsg}` : status;
|
|
||||||
|
|
||||||
const btn = document.createElement('button');
|
const btn = document.createElement('button');
|
||||||
btn.type = 'button';
|
btn.type = 'button';
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue