lib/irc: add formatURL

This commit is contained in:
Simon Ser 2023-04-19 11:43:45 +02:00
parent 57809be989
commit 57f64e9cc2
4 changed files with 18 additions and 16 deletions

View file

@ -43,22 +43,14 @@ export const BufferEventsDisplayMode = {
export const SettingsContext = createContext("settings");
export function getNickURL(nick) {
return "irc:///" + encodeURIComponent(nick) + ",isuser";
}
export function getChannelURL(channel) {
return "irc:///" + encodeURIComponent(channel);
}
export function getBufferURL(buf) {
switch (buf.type) {
case BufferType.SERVER:
return "irc:///";
return irc.formatURL();
case BufferType.CHANNEL:
return getChannelURL(buf.name);
return irc.formatURL({ entity: buf.name });
case BufferType.NICK:
return getNickURL(buf.name);
return irc.formatURL({ entity: buf.name, enttype: "user" });
}
throw new Error("Unknown buffer type: " + buf.type);
}