mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
Send WHO query when opening nick buffer
This commit is contained in:
parent
74b720c131
commit
57ed3a13a3
3 changed files with 43 additions and 9 deletions
|
@ -122,7 +122,8 @@ export default class App extends Component {
|
|||
buffers.set(name, {
|
||||
name,
|
||||
type,
|
||||
topic: null,
|
||||
topic: null, // if channel
|
||||
who: null, // if nick
|
||||
members: new Map(),
|
||||
messages: [],
|
||||
unread: Unread.NONE,
|
||||
|
@ -240,6 +241,21 @@ export default class App extends Component {
|
|||
break;
|
||||
case irc.RPL_ENDOFNAMES:
|
||||
break;
|
||||
case irc.RPL_WHOREPLY:
|
||||
var last = msg.params[msg.params.length - 1];
|
||||
var who = {
|
||||
username: msg.params[2],
|
||||
hostname: msg.params[3],
|
||||
server: msg.params[4],
|
||||
nick: msg.params[5],
|
||||
away: msg.params[6] == 'G', // H for here, G for gone
|
||||
realname: last.slice(last.indexOf(" ") + 1),
|
||||
};
|
||||
|
||||
this.setBufferState(who.nick, { who });
|
||||
break;
|
||||
case irc.RPL_ENDOFWHO:
|
||||
break;
|
||||
case "NOTICE":
|
||||
case "PRIVMSG":
|
||||
var target = msg.params[0];
|
||||
|
@ -335,6 +351,8 @@ export default class App extends Component {
|
|||
open(target) {
|
||||
if (this.isChannel(target)) {
|
||||
this.client.send({ command: "JOIN", params: [target] });
|
||||
} else {
|
||||
this.client.send({ command: "WHO", params: [target] });
|
||||
}
|
||||
this.createBuffer(target);
|
||||
this.switchBuffer(target);
|
||||
|
@ -470,7 +488,7 @@ export default class App extends Component {
|
|||
}
|
||||
|
||||
var topbar = null;
|
||||
if (activeBuffer && this.isChannel(activeBuffer.name)) {
|
||||
if (activeBuffer && activeBuffer.type != BufferType.SERVER) {
|
||||
topbar = html`
|
||||
<section id="topbar">
|
||||
<${BufferHeader} buffer=${activeBuffer} onClose=${() => this.close(activeBuffer.name)}/>
|
||||
|
|
|
@ -1,20 +1,34 @@
|
|||
import { html, Component } from "/lib/index.js";
|
||||
import { BufferType } from "/state.js";
|
||||
|
||||
export default function BufferHeader(props) {
|
||||
var topic = null;
|
||||
if (props.buffer.topic) {
|
||||
topic = html`<span class="topic">${props.buffer.topic}</span>`;
|
||||
}
|
||||
|
||||
function handlePartClick(event) {
|
||||
event.preventDefault();
|
||||
props.onClose();
|
||||
}
|
||||
|
||||
var description = null;
|
||||
if (props.buffer.topic) {
|
||||
description = html`<span class="description">${props.buffer.topic}</span>`;
|
||||
} else if (props.buffer.who) {
|
||||
var who = props.buffer.who;
|
||||
description = html`<span class="description">${who.realname} (${who.username}@${who.hostname})</span>`;
|
||||
}
|
||||
|
||||
var closeText = "Close";
|
||||
switch (props.buffer.type) {
|
||||
case BufferType.SERVER:
|
||||
closeText = "Disconnect";
|
||||
break;
|
||||
case BufferType.CHANNEL:
|
||||
closeText = "Part";
|
||||
break;
|
||||
}
|
||||
|
||||
return html`
|
||||
${topic}
|
||||
${description}
|
||||
<span class="actions">
|
||||
<a href="#" onClick=${handlePartClick}>Part</a>
|
||||
<a href="#" onClick=${handlePartClick}>${closeText}</a>
|
||||
</span>
|
||||
`;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
export const RPL_WELCOME = "001";
|
||||
export const RPL_ENDOFWHO = "315";
|
||||
export const RPL_TOPIC = "332";
|
||||
export const RPL_WHOREPLY = "352";
|
||||
export const RPL_NAMREPLY = "353";
|
||||
export const RPL_ENDOFNAMES = "366";
|
||||
export const ERR_PASSWDMISMATCH = "464";
|
||||
|
|
Loading…
Reference in a new issue