mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
Add shift+click to channel links
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
type LinkType =
|
||||
| { type: "profile"; id: string }
|
||||
| { type: "navigate"; path: string }
|
||||
| { type: "navigate"; path: string; navigation_type?: null }
|
||||
| { type: "navigate"; path: string; navigation_type: 'channel'; channel_id: string }
|
||||
| { type: "external"; href: string; url: URL }
|
||||
| { type: "none" };
|
||||
|
||||
@@ -11,6 +12,8 @@ const ALLOWED_ORIGINS = [
|
||||
"local.revolt.chat",
|
||||
];
|
||||
|
||||
const CHANNEL_PATH_RE = /^\/server\/[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}\/channel\/[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}$/
|
||||
|
||||
export function determineLink(href?: string): LinkType {
|
||||
let internal,
|
||||
url: URL | null = null;
|
||||
@@ -27,6 +30,10 @@ export function determineLink(href?: string): LinkType {
|
||||
return { type: "profile", id };
|
||||
}
|
||||
} else {
|
||||
console.log(path)
|
||||
if(CHANNEL_PATH_RE.test(path)) {
|
||||
return { type: 'navigate', path, navigation_type: 'channel', channel_id: path.slice(43) }
|
||||
}
|
||||
return { type: "navigate", path };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user