diff --git a/static/js/04-main.js b/static/js/04-main.js index afab36f..4ec49f2 100644 --- a/static/js/04-main.js +++ b/static/js/04-main.js @@ -2,6 +2,31 @@ "use strict"; window.Glow = window.Glow || {}; +Glow.presenceModeLabel = mode => { + switch (String(mode || "").toLowerCase()) { + case "silent": + return "silent"; + case "focus": + return "focus"; + case "dnd": + return "do not disturb"; + default: + return "online"; + } +}; + +const originalUpdateAuthUI = Glow.updateAuthUI; +Glow.updateAuthUI = () => { + if (typeof originalUpdateAuthUI === "function") { + originalUpdateAuthUI(); + } + const user = Glow.state.currentUser; + if (user && Glow.els.headerAccount) { + const mode = Glow.presenceModeLabel(user.presence_mode); + Glow.els.headerAccount.textContent = `${user.username} · ${user.role} · ${mode}`; + } +}; + Glow.loadRooms = async () => { const previousSlug = Glow.state.activeRoom?.slug; const data = await Glow.apiRequest("/api/rooms");