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

@ -26,3 +26,24 @@ export const Unread = {
return (priority[a] > priority[b]) ? a : b;
},
};
export function getNickURL(nick) {
return "irc:///" + encodeURIComponent(nick) + ",isnick";
}
export function getBufferURL(buf) {
switch (buf.type) {
case BufferType.SERVER:
return "irc:///";
case BufferType.CHANNEL:
return "irc:///" + encodeURIComponent(buf.name);
case BufferType.NICK:
return getNickURL(buf.name);
}
throw new Error("Unknown buffer type: " + buf.type);
}
export function getMessageURL(buf, msg) {
var bufURL = getBufferURL(buf);
return bufURL + "#timestamp=" + encodeURIComponent(msg.tags.time);
}