aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-08-25 13:10:05 +0200
committerSimon Ser <contact@emersion.fr>2023-08-25 13:10:05 +0200
commit5e33919ccea49f2ba0804aad4bf6500a6d6677a8 (patch)
tree7427a1b3403182a07c7c0427f3df098396c05b1d
parent97b5970acbcd9b36c683c14b7866849856a6b7d9 (diff)
downloadgamja-5e33919ccea49f2ba0804aad4bf6500a6d6677a8.tar.gz
gamja-5e33919ccea49f2ba0804aad4bf6500a6d6677a8.zip
Show MONITOR online/offline notifications in user buffers
We were only showing QUIT, which was weird because it wouldn't say when the user becomes online again. Use MONITOR instead.
-rw-r--r--components/app.js15
-rw-r--r--components/buffer.js13
2 files changed, 24 insertions, 4 deletions
diff --git a/components/app.js b/components/app.js
index 69098d9..80c86d8 100644
--- a/components/app.js
+++ b/components/app.js
@@ -706,7 +706,7 @@ export default class App extends Component {
// Open a new buffer if the message doesn't come from me or is a
// self-message
- if ((!client.isMyNick(msg.prefix.name) || client.isMyNick(bufName)) && (msg.command != "PART" && msg.comand != "QUIT")) {
+ if ((!client.isMyNick(msg.prefix.name) || client.isMyNick(bufName)) && (msg.command != "PART" && msg.comand != "QUIT" && msg.command != irc.RPL_MONONLINE && msg.command != irc.RPL_MONOFFLINE)) {
this.createBuffer(serverID, bufName);
}
@@ -916,7 +916,7 @@ export default class App extends Component {
if (buf.server != serverID) {
return;
}
- if (!buf.members.has(msg.prefix.name) && client.cm(buf.name) !== client.cm(msg.prefix.name)) {
+ if (!buf.members.has(msg.prefix.name)) {
return;
}
affectedBuffers.push(buf.name);
@@ -972,6 +972,15 @@ export default class App extends Component {
case irc.RPL_INVITING:
channel = msg.params[2];
return [channel];
+ case irc.RPL_MONONLINE:
+ case irc.RPL_MONOFFLINE:
+ let targets = msg.params[1].split(",");
+ affectedBuffers = [];
+ for (let target of targets) {
+ let prefix = irc.parsePrefix(target);
+ affectedBuffers.push(prefix.name);
+ }
+ return affectedBuffers;
case irc.RPL_YOURHOST:
case irc.RPL_MYINFO:
case irc.RPL_ISUPPORT:
@@ -983,8 +992,6 @@ export default class App extends Component {
case irc.RPL_TOPICWHOTIME:
case irc.RPL_NAMREPLY:
case irc.RPL_ENDOFNAMES:
- case irc.RPL_MONONLINE:
- case irc.RPL_MONOFFLINE:
case irc.RPL_SASLSUCCESS:
case irc.RPL_CHANNEL_URL:
case "AWAY":
diff --git a/components/buffer.js b/components/buffer.js
index a165c5a..901310d 100644
--- a/components/buffer.js
+++ b/components/buffer.js
@@ -267,6 +267,13 @@ class LogLine extends Component {
let date = new Date(parseInt(msg.params[2], 10) * 1000);
content = html`Channel was created on ${date.toLocaleString()}`;
break;
+ // MONITOR messages are only displayed in user buffers
+ case irc.RPL_MONONLINE:
+ content = html`${createNick(buf.name)} is online`;
+ break;
+ case irc.RPL_MONOFFLINE:
+ content = html`${createNick(buf.name)} is offline`;
+ break;
default:
if (irc.isError(msg.command) && msg.command != irc.ERR_NOMOTD) {
lineClass = "error";
@@ -653,6 +660,7 @@ export default class Buffer extends Component {
let hasUnreadSeparator = false;
let prevDate = new Date();
let foldMessages = [];
+ let hasMonitor = false;
buf.messages.forEach((msg) => {
let sep = [];
@@ -660,6 +668,11 @@ export default class Buffer extends Component {
return;
}
+ if (!hasMonitor && (msg.command === irc.RPL_MONONLINE || msg.command === irc.RPL_MONOFFLINE)) {
+ hasMonitor = true;
+ return;
+ }
+
if (!hasUnreadSeparator && buf.type != BufferType.SERVER && !isMessageBeforeReceipt(msg, buf.prevReadReceipt)) {
sep.push(html`<${UnreadSeparator} key="unread"/>`);
hasUnreadSeparator = true;