mirror of
https://codeberg.org/emersion/gamja
synced 2025-03-13 07:48:37 +01:00
Send WHO query when opening nick buffer
This commit is contained in:
parent
74b720c131
commit
57ed3a13a3
@ -122,7 +122,8 @@ export default class App extends Component {
|
|||||||
buffers.set(name, {
|
buffers.set(name, {
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
topic: null,
|
topic: null, // if channel
|
||||||
|
who: null, // if nick
|
||||||
members: new Map(),
|
members: new Map(),
|
||||||
messages: [],
|
messages: [],
|
||||||
unread: Unread.NONE,
|
unread: Unread.NONE,
|
||||||
@ -240,6 +241,21 @@ export default class App extends Component {
|
|||||||
break;
|
break;
|
||||||
case irc.RPL_ENDOFNAMES:
|
case irc.RPL_ENDOFNAMES:
|
||||||
break;
|
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 "NOTICE":
|
||||||
case "PRIVMSG":
|
case "PRIVMSG":
|
||||||
var target = msg.params[0];
|
var target = msg.params[0];
|
||||||
@ -335,6 +351,8 @@ export default class App extends Component {
|
|||||||
open(target) {
|
open(target) {
|
||||||
if (this.isChannel(target)) {
|
if (this.isChannel(target)) {
|
||||||
this.client.send({ command: "JOIN", params: [target] });
|
this.client.send({ command: "JOIN", params: [target] });
|
||||||
|
} else {
|
||||||
|
this.client.send({ command: "WHO", params: [target] });
|
||||||
}
|
}
|
||||||
this.createBuffer(target);
|
this.createBuffer(target);
|
||||||
this.switchBuffer(target);
|
this.switchBuffer(target);
|
||||||
@ -470,7 +488,7 @@ export default class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var topbar = null;
|
var topbar = null;
|
||||||
if (activeBuffer && this.isChannel(activeBuffer.name)) {
|
if (activeBuffer && activeBuffer.type != BufferType.SERVER) {
|
||||||
topbar = html`
|
topbar = html`
|
||||||
<section id="topbar">
|
<section id="topbar">
|
||||||
<${BufferHeader} buffer=${activeBuffer} onClose=${() => this.close(activeBuffer.name)}/>
|
<${BufferHeader} buffer=${activeBuffer} onClose=${() => this.close(activeBuffer.name)}/>
|
||||||
|
@ -1,20 +1,34 @@
|
|||||||
import { html, Component } from "/lib/index.js";
|
import { html, Component } from "/lib/index.js";
|
||||||
|
import { BufferType } from "/state.js";
|
||||||
|
|
||||||
export default function BufferHeader(props) {
|
export default function BufferHeader(props) {
|
||||||
var topic = null;
|
|
||||||
if (props.buffer.topic) {
|
|
||||||
topic = html`<span class="topic">${props.buffer.topic}</span>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function handlePartClick(event) {
|
function handlePartClick(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
props.onClose();
|
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`
|
return html`
|
||||||
${topic}
|
${description}
|
||||||
<span class="actions">
|
<span class="actions">
|
||||||
<a href="#" onClick=${handlePartClick}>Part</a>
|
<a href="#" onClick=${handlePartClick}>${closeText}</a>
|
||||||
</span>
|
</span>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
export const RPL_WELCOME = "001";
|
export const RPL_WELCOME = "001";
|
||||||
|
export const RPL_ENDOFWHO = "315";
|
||||||
export const RPL_TOPIC = "332";
|
export const RPL_TOPIC = "332";
|
||||||
|
export const RPL_WHOREPLY = "352";
|
||||||
export const RPL_NAMREPLY = "353";
|
export const RPL_NAMREPLY = "353";
|
||||||
export const RPL_ENDOFNAMES = "366";
|
export const RPL_ENDOFNAMES = "366";
|
||||||
export const ERR_PASSWDMISMATCH = "464";
|
export const ERR_PASSWDMISMATCH = "464";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user