diff --git a/components/app.js b/components/app.js index 52b2459..3cbf5c8 100644 --- a/components/app.js +++ b/components/app.js @@ -122,6 +122,7 @@ export default class App extends Component { buffers.set(name, { name, type, + serverInfo: null, // if server topic: null, // if channel who: null, // if nick members: new Map(), @@ -219,6 +220,14 @@ export default class App extends Component { }); } break; + case irc.RPL_MYINFO: + // TODO: parse available modes + var serverInfo = { + name: msg.params[1], + version: msg.params[2], + }; + this.setBufferState(SERVER_BUFFER, { serverInfo }); + break; case irc.RPL_TOPIC: var channel = msg.params[1]; var topic = msg.params[2]; @@ -488,7 +497,7 @@ export default class App extends Component { } var topbar = null; - if (activeBuffer && activeBuffer.type != BufferType.SERVER) { + if (activeBuffer) { topbar = html`
<${BufferHeader} buffer=${activeBuffer} onClose=${() => this.close(activeBuffer.name)}/> diff --git a/components/buffer-header.js b/components/buffer-header.js index 1e8d762..0c80f23 100644 --- a/components/buffer-header.js +++ b/components/buffer-header.js @@ -8,11 +8,14 @@ export default function BufferHeader(props) { } var description = null; - if (props.buffer.topic) { - description = html`${props.buffer.topic}`; + if (props.buffer.serverInfo) { + var serverInfo = props.buffer.serverInfo; + description = `Connected to ${serverInfo.name}`; + } else if (props.buffer.topic) { + description = props.buffer.topic; } else if (props.buffer.who) { var who = props.buffer.who; - description = html`${who.realname} (${who.username}@${who.hostname})`; + description = `${who.realname} (${who.username}@${who.hostname})`; } var closeText = "Close"; @@ -26,7 +29,7 @@ export default function BufferHeader(props) { } return html` - ${description} + ${description} ${closeText} diff --git a/lib/irc.js b/lib/irc.js index b9a5565..dd138f2 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -1,4 +1,7 @@ export const RPL_WELCOME = "001"; +export const RPL_YOURHOST = "002"; +export const RPL_CREATED = "003"; +export const RPL_MYINFO = "004"; export const RPL_ENDOFWHO = "315"; export const RPL_TOPIC = "332"; export const RPL_WHOREPLY = "352";