Pretty-print buffer name in buffer header

This commit is contained in:
Simon Ser 2021-05-31 17:39:37 +02:00
parent 6e16163103
commit bc7162ebe2
3 changed files with 24 additions and 19 deletions

View file

@ -1,7 +1,7 @@
import { html, Component } from "../lib/index.js";
import linkify from "../lib/linkify.js";
import { strip as stripANSI } from "../lib/ansi.js";
import { BufferType, NetworkStatus } from "../state.js";
import { BufferType, NetworkStatus, getNetworkName } from "../state.js";
const UserStatus = {
HERE: "here",
@ -154,8 +154,13 @@ export default function BufferHeader(props) {
break;
}
var name = props.buffer.name;
if (props.buffer.type == BufferType.SERVER) {
name = getNetworkName(props.network, props.bouncerNetwork, props.isBouncer);
}
return html`
<span class="title">${props.buffer.name}</span>
<span class="title">${name}</span>
<span class="description">${description}</span>
<span class="actions">${actions}</span>
`;

View file

@ -1,22 +1,6 @@
import * as irc from "../lib/irc.js";
import { html, Component } from "../lib/index.js";
import { BufferType, Unread, getBufferURL } from "../state.js";
function getNetworkName(network, bouncerNetwork, bouncer) {
if (bouncerNetwork && bouncerNetwork.name) {
return bouncerNetwork.name;
}
if (bouncer) {
return "bouncer";
}
var netName = network.isupport.get("NETWORK");
if (netName) {
return netName;
}
return "server";
}
import { BufferType, Unread, getBufferURL, getNetworkName } from "../state.js";
function BufferItem(props) {
function handleClick(event) {

View file

@ -54,3 +54,19 @@ export function getMessageURL(buf, msg) {
return bufURL + "?timestamp=" + encodeURIComponent(msg.tags.time);
}
}
export function getNetworkName(network, bouncerNetwork, isBouncer) {
if (bouncerNetwork && bouncerNetwork.name) {
return bouncerNetwork.name;
}
if (isBouncer) {
return "bouncer";
}
var netName = network.isupport.get("NETWORK");
if (netName) {
return netName;
}
return "server";
}