From e6ad6a552ef26197cc87cd42ebe8c1ba2f2f1ece Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Sun, 18 Sep 2022 12:05:48 +0100 Subject: [PATCH 1/2] feat: add focus mode --- external/components | 2 +- external/lang | 2 +- external/revolt.js | 2 +- src/components/common/user/UserIcon.tsx | 2 ++ src/components/common/user/UserStatus.tsx | 4 ++++ src/context/Theme.tsx | 8 +++++--- src/lib/ContextMenus.tsx | 9 +++++++++ src/mobx/stores/NotificationOptions.ts | 9 ++++++++- src/styles/_context-menu.scss | 4 ++++ yarn.lock | 10 +++++----- 10 files changed, 40 insertions(+), 12 deletions(-) diff --git a/external/components b/external/components index 55709411..ab0fc1af 160000 --- a/external/components +++ b/external/components @@ -1 +1 @@ -Subproject commit 557094115d17a363eb6fb8f27c6e697e049ce623 +Subproject commit ab0fc1af739f877c8f416dcd7e47d25aacbb7eea diff --git a/external/lang b/external/lang index 14d51d68..843cece2 160000 --- a/external/lang +++ b/external/lang @@ -1 +1 @@ -Subproject commit 14d51d68a579ee3796837cd16deda4281f83c923 +Subproject commit 843cece2854185651e17765bcb78109d22eba769 diff --git a/external/revolt.js b/external/revolt.js index 044b1b91..ab064f41 160000 --- a/external/revolt.js +++ b/external/revolt.js @@ -1 +1 @@ -Subproject commit 044b1b91ee583bfb89fff140ecda29a32f6535aa +Subproject commit ab064f41a4154acee7c1751ea5b59d9ee4345a0b diff --git a/src/components/common/user/UserIcon.tsx b/src/components/common/user/UserIcon.tsx index 3c96b9a6..fca6cde3 100644 --- a/src/components/common/user/UserIcon.tsx +++ b/src/components/common/user/UserIcon.tsx @@ -25,6 +25,8 @@ export function useStatusColour(user?: User) { return user?.online && user?.status?.presence !== "Invisible" ? user?.status?.presence === "Idle" ? theme.getVariable("status-away") + : user?.status?.presence === "Focus" + ? theme.getVariable("status-focus") : user?.status?.presence === "Busy" ? theme.getVariable("status-busy") : theme.getVariable("status-online") diff --git a/src/components/common/user/UserStatus.tsx b/src/components/common/user/UserStatus.tsx index 36e866c4..137cf630 100644 --- a/src/components/common/user/UserStatus.tsx +++ b/src/components/common/user/UserStatus.tsx @@ -32,6 +32,10 @@ export default observer(({ user, tooltip }: Props) => { return ; } + if (user.status?.presence === "Focus") { + return ; + } + if (user.status?.presence === "Invisible") { return ; } diff --git a/src/context/Theme.tsx b/src/context/Theme.tsx index 9d8ec18b..f079c9e9 100644 --- a/src/context/Theme.tsx +++ b/src/context/Theme.tsx @@ -31,6 +31,7 @@ export type Variables = | "tooltip" | "status-online" | "status-away" + | "status-focus" | "status-busy" | "status-streaming" | "status-invisible"; @@ -283,6 +284,7 @@ export const PRESETS: Record = { "tertiary-foreground": "#3a3a3a", "status-online": "#3ABF7E", "status-away": "#F39F00", + "status-focus": "#4799F0", "status-busy": "#F84848", "status-streaming": "#977EFF", "status-invisible": "#A5A5A5", @@ -310,6 +312,7 @@ export const PRESETS: Record = { "tertiary-foreground": "#848484", "status-online": "#3ABF7E", "status-away": "#F39F00", + "status-focus": "#4799F0", "status-busy": "#F84848", "status-streaming": "#977EFF", "status-invisible": "#A5A5A5", @@ -336,9 +339,8 @@ export const generateVariables = (theme: Theme) => { if (colour) { const [r, g, b] = colour; return `--${key}: ${theme[key]}; --${key}-rgb: ${r}, ${g}, ${b};`; - } - return `--${key}: ${theme[key]};`; - + } + return `--${key}: ${theme[key]};`; }); }; diff --git a/src/lib/ContextMenus.tsx b/src/lib/ContextMenus.tsx index 6aeb7c41..3298a4aa 100644 --- a/src/lib/ContextMenus.tsx +++ b/src/lib/ContextMenus.tsx @@ -1110,6 +1110,15 @@ export default function ContextMenus() {
+ +
+ + Date: Sun, 18 Sep 2022 12:32:29 +0100 Subject: [PATCH 2/2] fix: correctly match protocols --- src/lib/links.ts | 51 +++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/src/lib/links.ts b/src/lib/links.ts index 1a04e14f..211c91d6 100644 --- a/src/lib/links.ts +++ b/src/lib/links.ts @@ -1,3 +1,6 @@ +/** + * Type of link + */ type LinkType = | { type: "navigate"; @@ -6,6 +9,9 @@ type LinkType = | { type: "external"; href: string; url: URL } | { type: "none" }; +/** + * Allowed origins for relative navigation + */ const ALLOWED_ORIGINS = [ location.hostname, "app.revolt.chat", @@ -13,27 +19,36 @@ const ALLOWED_ORIGINS = [ "local.revolt.chat", ]; +/** + * Permissible protocols in URLs + */ const PROTOCOL_WHITELIST = [ - "https", - "ftp", - "ftps", - "mailto", - "news", - "irc", - "gopher", - "nntp", - "feed", - "telnet", - "mms", - "rtsp", - "svn", - "git", - "tel", - "fax", - "xmpp", - "magnet", + "http:", + "https:", + "ftp:", + "ftps:", + "mailto:", + "news:", + "irc:", + "gopher:", + "nntp:", + "feed:", + "telnet:", + "mms:", + "rtsp:", + "svn:", + "git:", + "tel:", + "fax:", + "xmpp:", + "magnet:", ]; +/** + * Determine what kind of link we are dealing with and sanitise any malicious input + * @param href Input URL + * @returns Link Type + */ export function determineLink(href?: string): LinkType { let internal, url: URL | null = null;