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.
This commit is contained in:
Simon Ser 2023-08-25 13:10:05 +02:00
parent 97b5970acb
commit 5e33919cce
2 changed files with 24 additions and 4 deletions

View file

@ -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 // Open a new buffer if the message doesn't come from me or is a
// self-message // 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); this.createBuffer(serverID, bufName);
} }
@ -916,7 +916,7 @@ export default class App extends Component {
if (buf.server != serverID) { if (buf.server != serverID) {
return; 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; return;
} }
affectedBuffers.push(buf.name); affectedBuffers.push(buf.name);
@ -972,6 +972,15 @@ export default class App extends Component {
case irc.RPL_INVITING: case irc.RPL_INVITING:
channel = msg.params[2]; channel = msg.params[2];
return [channel]; 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_YOURHOST:
case irc.RPL_MYINFO: case irc.RPL_MYINFO:
case irc.RPL_ISUPPORT: case irc.RPL_ISUPPORT:
@ -983,8 +992,6 @@ export default class App extends Component {
case irc.RPL_TOPICWHOTIME: case irc.RPL_TOPICWHOTIME:
case irc.RPL_NAMREPLY: case irc.RPL_NAMREPLY:
case irc.RPL_ENDOFNAMES: case irc.RPL_ENDOFNAMES:
case irc.RPL_MONONLINE:
case irc.RPL_MONOFFLINE:
case irc.RPL_SASLSUCCESS: case irc.RPL_SASLSUCCESS:
case irc.RPL_CHANNEL_URL: case irc.RPL_CHANNEL_URL:
case "AWAY": case "AWAY":

View file

@ -267,6 +267,13 @@ class LogLine extends Component {
let date = new Date(parseInt(msg.params[2], 10) * 1000); let date = new Date(parseInt(msg.params[2], 10) * 1000);
content = html`Channel was created on ${date.toLocaleString()}`; content = html`Channel was created on ${date.toLocaleString()}`;
break; 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: default:
if (irc.isError(msg.command) && msg.command != irc.ERR_NOMOTD) { if (irc.isError(msg.command) && msg.command != irc.ERR_NOMOTD) {
lineClass = "error"; lineClass = "error";
@ -653,6 +660,7 @@ export default class Buffer extends Component {
let hasUnreadSeparator = false; let hasUnreadSeparator = false;
let prevDate = new Date(); let prevDate = new Date();
let foldMessages = []; let foldMessages = [];
let hasMonitor = false;
buf.messages.forEach((msg) => { buf.messages.forEach((msg) => {
let sep = []; let sep = [];
@ -660,6 +668,11 @@ export default class Buffer extends Component {
return; 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)) { if (!hasUnreadSeparator && buf.type != BufferType.SERVER && !isMessageBeforeReceipt(msg, buf.prevReadReceipt)) {
sep.push(html`<${UnreadSeparator} key="unread"/>`); sep.push(html`<${UnreadSeparator} key="unread"/>`);
hasUnreadSeparator = true; hasUnreadSeparator = true;