chore(instances): harden presence refresh and fix lint

This commit is contained in:
Peter Steinberger
2025-12-09 04:51:54 +01:00
parent 658e0c6b03
commit f0860ec145
7 changed files with 53 additions and 13 deletions

View File

@@ -59,6 +59,17 @@ function ensureSelfPresence() {
}
}
function touchSelfPresence() {
const host = os.hostname();
const key = host.toLowerCase();
const existing = entries.get(key);
if (existing) {
entries.set(key, { ...existing, ts: Date.now() });
} else {
initSelfPresence();
}
}
initSelfPresence();
function parsePresence(text: string): SystemPresence {
@@ -96,5 +107,6 @@ export function updateSystemPresence(text: string) {
export function listSystemPresence(): SystemPresence[] {
ensureSelfPresence();
touchSelfPresence();
return [...entries.values()].sort((a, b) => b.ts - a.ts);
}