Add message URLs, unify URL generation

This commit is contained in:
Simon Ser 2020-07-15 18:47:33 +02:00
parent 36df984b09
commit 0d9f7f35f0
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
4 changed files with 31 additions and 24 deletions

View file

@ -1,5 +1,5 @@
import { html, Component } from "/lib/index.js";
import { BufferType, Unread } from "/state.js";
import { BufferType, Unread, getBufferURL } from "/state.js";
function BufferItem(props) {
function handleClick(event) {
@ -19,22 +19,9 @@ function BufferItem(props) {
unreadClass = "unread-" + props.buffer.unread;
}
var url = "#";
switch (props.buffer.type) {
case BufferType.SERVER:
url = "irc:///";
break;
case BufferType.CHANNEL:
url = "irc:///" + encodeURIComponent(props.buffer.name);
break;
case BufferType.NICK:
url = "irc:///" + encodeURIComponent(props.buffer.name) + ",isnick";
break;
}
return html`
<li class="${activeClass} ${unreadClass}">
<a href=${url} onClick=${handleClick}>${name}</a>
<a href=${getBufferURL(props.buffer)} onClick=${handleClick}>${name}</a>
</li>
`;
}