mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
Extract network name from ISUPPORT
This commit is contained in:
parent
b3f8b0c97d
commit
51523f4014
3 changed files with 23 additions and 5 deletions
|
@ -1020,7 +1020,7 @@ export default class App extends Component {
|
|||
|
||||
return html`
|
||||
<section id="buffer-list">
|
||||
<${BufferList} buffers=${this.state.buffers} activeBuffer=${this.state.activeBuffer} onBufferClick=${this.handleBufferListClick}/>
|
||||
<${BufferList} buffers=${this.state.buffers} networks=${this.state.networks} activeBuffer=${this.state.activeBuffer} onBufferClick=${this.handleBufferListClick}/>
|
||||
<div class="actions">
|
||||
<a href="#" onClick=${this.handleJoinClick}>Join channel</a>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,24 @@
|
|||
import * as irc from "/lib/irc.js";
|
||||
import { html, Component } from "/lib/index.js";
|
||||
import { BufferType, Unread, getBufferURL } from "/state.js";
|
||||
|
||||
function getNetworkName(network) {
|
||||
var bouncerStr = network.isupport.get("BOUNCER");
|
||||
if (bouncerStr) {
|
||||
var bouncerProps = irc.parseTags(bouncerStr);
|
||||
if (bouncerProps["network"]) {
|
||||
return bouncerProps["network"];
|
||||
}
|
||||
}
|
||||
|
||||
var netName = network.isupport.get("NETWORK");
|
||||
if (netName) {
|
||||
return netName;
|
||||
}
|
||||
|
||||
return "server";
|
||||
}
|
||||
|
||||
function BufferItem(props) {
|
||||
function handleClick(event) {
|
||||
event.preventDefault();
|
||||
|
@ -9,7 +27,7 @@ function BufferItem(props) {
|
|||
|
||||
var name = props.buffer.name;
|
||||
if (props.buffer.type == BufferType.SERVER) {
|
||||
name = "server";
|
||||
name = getNetworkName(props.network);
|
||||
}
|
||||
|
||||
var activeClass = props.active ? "active" : "";
|
||||
|
@ -31,7 +49,7 @@ export default function BufferList(props) {
|
|||
return html`
|
||||
<ul>
|
||||
${Array.from(props.buffers.values()).map((buf) => html`
|
||||
<${BufferItem} key=${buf.id} buffer=${buf} onClick=${() => props.onBufferClick(buf.name)} active=${props.activeBuffer == buf.id}/>
|
||||
<${BufferItem} key=${buf.id} buffer=${buf} network=${props.networks.get(buf.network)} onClick=${() => props.onBufferClick(buf.name)} active=${props.activeBuffer == buf.id}/>
|
||||
`)}
|
||||
</ul>
|
||||
`;
|
||||
|
|
|
@ -50,7 +50,7 @@ function unescapeTag(s) {
|
|||
return s.replace(/\\[:s\\rn]/, (seq) => tagUnescapeMap[seq]);
|
||||
}
|
||||
|
||||
function parseTags(s) {
|
||||
export function parseTags(s) {
|
||||
var tags = {};
|
||||
s.split(";").forEach(function(s) {
|
||||
if (!s) {
|
||||
|
@ -70,7 +70,7 @@ function parseTags(s) {
|
|||
return tags;
|
||||
}
|
||||
|
||||
function formatTags(tags) {
|
||||
export function formatTags(tags) {
|
||||
var l = [];
|
||||
for (var k in tags) {
|
||||
var v = escapeTag(tags[k]);
|
||||
|
|
Loading…
Reference in a new issue