From 0bd2e106313a37cd113281c1470c32f0f7619be2 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 26 Jun 2020 12:45:27 +0200 Subject: [PATCH] Add away indicator --- components/app.js | 8 ++++++++ components/buffer-header.js | 11 ++++++++++- lib/client.js | 2 +- style.css | 7 +++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/components/app.js b/components/app.js index 3cbf5c8..1075e8d 100644 --- a/components/app.js +++ b/components/app.js @@ -327,6 +327,14 @@ export default class App extends Component { this.setBufferState(channel, { topic }); this.addMessage(channel, msg); break; + case "AWAY": + var awayMessage = msg.params[0]; + + this.setBufferState(msg.prefix.name, (buf) => { + var who = { ...buf.who, away: !!awayMessage }; + return { who }; + }); + break; case "CAP": case "AUTHENTICATE": // Ignore these diff --git a/components/buffer-header.js b/components/buffer-header.js index 0c80f23..641b43e 100644 --- a/components/buffer-header.js +++ b/components/buffer-header.js @@ -15,7 +15,16 @@ export default function BufferHeader(props) { description = props.buffer.topic; } else if (props.buffer.who) { var who = props.buffer.who; - description = `${who.realname} (${who.username}@${who.hostname})`; + + var statusClass = "here"; + var statusText = "User is online"; + if (who.away) { + statusClass = "gone"; + statusText = "User is away"; + } + var status = html``; + + description = html`${status} ${who.realname} (${who.username}@${who.hostname})`; } var closeText = "Close"; diff --git a/lib/client.js b/lib/client.js index dc8e3a4..b32dc68 100644 --- a/lib/client.js +++ b/lib/client.js @@ -2,7 +2,7 @@ import * as irc from "./irc.js"; // Static list of capabilities that are always requested when supported by the // server -const permanentCaps = ["message-tags", "server-time", "multi-prefix"]; +const permanentCaps = ["message-tags", "server-time", "multi-prefix", "away-notify"]; export default class Client extends EventTarget { ws = null; diff --git a/style.css b/style.css index b1c86e9..51e2dea 100644 --- a/style.css +++ b/style.css @@ -51,6 +51,13 @@ body { border-bottom: 1px solid #e3e3e3; } +#topbar .status-here { + color: green; +} +#topbar .status-gone { + color: orange; +} + #topbar .actions { float: right; }