From ffee147aede020d421df899adb5328df3419bd5d Mon Sep 17 00:00:00 2001 From: Declan Chidlow Date: Wed, 5 Jun 2024 15:33:48 +0800 Subject: [PATCH] Fix ability to set appearence of Focus status and remove unused references to streaming status --- src/components/markdown/plugins/htmlToText.ts | 20 ++++++------- .../appearance/legacy/ThemeOverrides.tsx | 4 +-- .../settings/roles/PermissionSelect.tsx | 11 ++++--- src/context/Theme.tsx | 9 ++---- src/controllers/client/jsx/error.tsx | 2 +- .../modals/components/CreateInvite.tsx | 6 ++-- src/lib/ContextMenus.tsx | 30 ++++++++++--------- src/mobx/stores/helpers/SAudio.ts | 11 ++++--- src/mobx/stores/helpers/STheme.ts | 2 +- src/pages/home/Home.tsx | 2 +- src/styles/_context-menu.scss | 2 +- src/sw.ts | 2 +- 12 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/components/markdown/plugins/htmlToText.ts b/src/components/markdown/plugins/htmlToText.ts index abcbbcdb..2442f18e 100644 --- a/src/components/markdown/plugins/htmlToText.ts +++ b/src/components/markdown/plugins/htmlToText.ts @@ -1,10 +1,10 @@ -import { Plugin } from "unified"; -import { visit } from "unist-util-visit"; - -export const remarkHtmlToText: Plugin = () => { - return (tree) => { - visit(tree, "html", (node: { type: string; value: string }) => { - node.type = "text"; - }); - }; -}; +import { Plugin } from "unified"; +import { visit } from "unist-util-visit"; + +export const remarkHtmlToText: Plugin = () => { + return (tree) => { + visit(tree, "html", (node: { type: string; value: string }) => { + node.type = "text"; + }); + }; +}; diff --git a/src/components/settings/appearance/legacy/ThemeOverrides.tsx b/src/components/settings/appearance/legacy/ThemeOverrides.tsx index 3483b510..1df10a84 100644 --- a/src/components/settings/appearance/legacy/ThemeOverrides.tsx +++ b/src/components/settings/appearance/legacy/ThemeOverrides.tsx @@ -106,9 +106,9 @@ export default observer(() => { "scrollbar-thumb", "scrollbar-track", "status-online", - "status-away", + "status-idle", + "status-focus", "status-busy", - "status-streaming", "status-invisible", "success", "warning", diff --git a/src/components/settings/roles/PermissionSelect.tsx b/src/components/settings/roles/PermissionSelect.tsx index 7de9ac23..b44ac29f 100644 --- a/src/components/settings/roles/PermissionSelect.tsx +++ b/src/components/settings/roles/PermissionSelect.tsx @@ -67,13 +67,12 @@ export function PermissionSelect({ } return "Neutral"; - } - if (Long.fromNumber(value).and(permission).eq(permission)) { - return "Allow"; - } + } + if (Long.fromNumber(value).and(permission).eq(permission)) { + return "Allow"; + } - return "Neutral"; - + return "Neutral"; }, [value]); function onSwitch(state: State) { diff --git a/src/context/Theme.tsx b/src/context/Theme.tsx index f079c9e9..fb755140 100644 --- a/src/context/Theme.tsx +++ b/src/context/Theme.tsx @@ -30,10 +30,9 @@ export type Variables = | "tertiary-foreground" | "tooltip" | "status-online" - | "status-away" + | "status-idle" | "status-focus" | "status-busy" - | "status-streaming" | "status-invisible"; // While this isn't used, it'd be good to keep this up to date as a reference or for future use @@ -283,10 +282,9 @@ export const PRESETS: Record = { "tertiary-background": "#4D4D4D", "tertiary-foreground": "#3a3a3a", "status-online": "#3ABF7E", - "status-away": "#F39F00", + "status-idle": "#F39F00", "status-focus": "#4799F0", "status-busy": "#F84848", - "status-streaming": "#977EFF", "status-invisible": "#A5A5A5", }, dark: { @@ -311,10 +309,9 @@ export const PRESETS: Record = { "tertiary-background": "#4D4D4D", "tertiary-foreground": "#848484", "status-online": "#3ABF7E", - "status-away": "#F39F00", + "status-idle": "#F39F00", "status-focus": "#4799F0", "status-busy": "#F84848", - "status-streaming": "#977EFF", "status-invisible": "#A5A5A5", }, }; diff --git a/src/controllers/client/jsx/error.tsx b/src/controllers/client/jsx/error.tsx index 144b0fd9..8a732445 100644 --- a/src/controllers/client/jsx/error.tsx +++ b/src/controllers/client/jsx/error.tsx @@ -10,7 +10,7 @@ export function takeError(error: any): string { case 429: return "TooManyRequests"; case 401: - return "Unauthorized" + return "Unauthorized"; case 403: return "Forbidden"; default: diff --git a/src/controllers/modals/components/CreateInvite.tsx b/src/controllers/modals/components/CreateInvite.tsx index 28e7a7d1..df8952ee 100644 --- a/src/controllers/modals/components/CreateInvite.tsx +++ b/src/controllers/modals/components/CreateInvite.tsx @@ -7,10 +7,10 @@ import { ModalForm } from "@revoltchat/ui"; import { noopAsync } from "../../../lib/js"; +import { IS_REVOLT } from "../../../version"; import { takeError } from "../../client/jsx/error"; import { modalController } from "../ModalController"; import { ModalProps } from "../types"; -import { IS_REVOLT } from "../../../version"; /** * Code block which displays invite @@ -79,7 +79,9 @@ export default function CreateInvite({ children: , onClick: () => modalController.writeText( - IS_REVOLT ? `https://rvlt.gg/${code}` : `${window.location.host}/invite/${code}` + IS_REVOLT + ? `https://rvlt.gg/${code}` + : `${window.location.host}/invite/${code}`, ), }, ]} diff --git a/src/lib/ContextMenus.tsx b/src/lib/ContextMenus.tsx index 55c2dbb7..cc4c7721 100644 --- a/src/lib/ContextMenus.tsx +++ b/src/lib/ContextMenus.tsx @@ -2,29 +2,32 @@ import { ChevronRight, Trash } from "@styled-icons/boxicons-regular"; import { Cog, UserVoice } from "@styled-icons/boxicons-solid"; import { isFirefox } from "react-device-detect"; import { useHistory } from "react-router-dom"; -import { Channel, Message, Server, User, API, Permission, UserPermission, Member } from "revolt.js"; +import { + Channel, + Message, + Server, + User, + API, + Permission, + UserPermission, + Member, +} from "revolt.js"; - - -import { ContextMenuWithData, MenuItem, openContextMenu } from "preact-context-menu"; +import { + ContextMenuWithData, + MenuItem, + openContextMenu, +} from "preact-context-menu"; import { Text } from "preact-i18n"; - - import { Column, IconButton, LineDivider } from "@revoltchat/ui"; - - import { useApplicationState } from "../mobx/State"; import { QueuedMessage } from "../mobx/stores/MessageQueue"; import { NotificationState } from "../mobx/stores/NotificationOptions"; - - import CMNotifications from "./contextmenu/CMNotifications"; - - import Tooltip from "../components/common/Tooltip"; import UserStatus from "../components/common/user/UserStatus"; import { useSession } from "../controllers/client/ClientController"; @@ -33,7 +36,6 @@ import { modalController } from "../controllers/modals/ModalController"; import { internalEmit } from "./eventEmitter"; import { getRenderer } from "./renderer/Singleton"; - interface ContextMenuData { user?: string; server?: string; @@ -1293,4 +1295,4 @@ export default function ContextMenus() { ); -} \ No newline at end of file +} diff --git a/src/mobx/stores/helpers/SAudio.ts b/src/mobx/stores/helpers/SAudio.ts index a8256e3e..dbcec764 100644 --- a/src/mobx/stores/helpers/SAudio.ts +++ b/src/mobx/stores/helpers/SAudio.ts @@ -82,11 +82,10 @@ export default class SAudio { getAudio(path: string) { if (this.cache.has(path)) { return this.cache.get(path)!; - } - const el = new Audio(path); - this.cache.set(path, el); - return el; - + } + const el = new Audio(path); + this.cache.set(path, el); + return el; } loadCache() { @@ -100,7 +99,7 @@ export default class SAudio { try { audio.play(); } catch (err) { - console.error("Hit error while playing", `${sound }:`, err); + console.error("Hit error while playing", `${sound}:`, err); } } } diff --git a/src/mobx/stores/helpers/STheme.ts b/src/mobx/stores/helpers/STheme.ts index cde02cf3..a836d708 100644 --- a/src/mobx/stores/helpers/STheme.ts +++ b/src/mobx/stores/helpers/STheme.ts @@ -110,7 +110,7 @@ export default class STheme { for (const key of Object.keys(variables)) { const value = variables[key]; if (typeof value === "string") { - variables[`${key }-contrast`] = getContrastingColour(value); + variables[`${key}-contrast`] = getContrastingColour(value); } } diff --git a/src/pages/home/Home.tsx b/src/pages/home/Home.tsx index 1d6e6d2f..1af3a1d2 100644 --- a/src/pages/home/Home.tsx +++ b/src/pages/home/Home.tsx @@ -51,7 +51,7 @@ export default observer(() => { state.settings.set("appearance:seasonal", !seasonalTheme); const isDecember = !isTouchscreenDevice && new Date().getMonth() === 11; - const isOctober = !isTouchscreenDevice && new Date().getMonth() === 9 + const isOctober = !isTouchscreenDevice && new Date().getMonth() === 9; const snowflakes = useMemo(() => { const flakes: string[] = []; diff --git a/src/styles/_context-menu.scss b/src/styles/_context-menu.scss index 6c0f2f46..20e645e4 100644 --- a/src/styles/_context-menu.scss +++ b/src/styles/_context-menu.scss @@ -89,7 +89,7 @@ } &.idle { - background: var(--status-away); + background: var(--status-idle); } &.focus { diff --git a/src/sw.ts b/src/sw.ts index 1daec57c..ceec474f 100644 --- a/src/sw.ts +++ b/src/sw.ts @@ -29,7 +29,7 @@ precacheAndRoute( } for (const key of locale_keys) { - if (fn.startsWith(`${key }.`)) { + if (fn.startsWith(`${key}.`)) { return false; } }