From 67834309b125d23079a7e2aa6d23469ace223ba9 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 14 Nov 2021 19:53:50 +0000 Subject: [PATCH] fix: use masquerade everywhere applicable fixes #400 --- src/components/common/messaging/Message.tsx | 8 ++++---- .../messaging/attachments/MessageReply.tsx | 3 ++- .../common/messaging/bars/ReplyBar.tsx | 6 ++---- src/components/common/user/UserIcon.tsx | 9 +++++++-- src/components/common/user/UserShort.tsx | 20 ++++++++++++------- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/components/common/messaging/Message.tsx b/src/components/common/messaging/Message.tsx index 63ce0eb3..5eae1ed9 100644 --- a/src/components/common/messaging/Message.tsx +++ b/src/components/common/messaging/Message.tsx @@ -146,12 +146,12 @@ const Message = observer( {head && (
{
diff --git a/src/components/common/user/UserIcon.tsx b/src/components/common/user/UserIcon.tsx index 731f0350..13a4911e 100644 --- a/src/components/common/user/UserIcon.tsx +++ b/src/components/common/user/UserIcon.tsx @@ -2,8 +2,10 @@ import { MicrophoneOff } from "@styled-icons/boxicons-regular"; import { VolumeMute } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { useParams } from "react-router-dom"; +import { Masquerade } from "revolt-api/types/Channels"; import { Presence } from "revolt-api/types/Users"; import { User } from "revolt.js/dist/maps/Users"; +import { Nullable } from "revolt.js/dist/util/null"; import styled, { css } from "styled-components"; import { useContext } from "preact/hooks"; @@ -17,9 +19,9 @@ import IconBase, { IconBaseProps } from "../IconBase"; type VoiceStatus = "muted" | "deaf"; interface Props extends IconBaseProps { - mask?: string; status?: boolean; voice?: VoiceStatus; + masquerade?: Masquerade; showServerIdentity?: boolean; } @@ -74,11 +76,14 @@ export default observer( mask, hover, showServerIdentity, + masquerade, ...svgProps } = props; let { url } = props; - if (!url) { + if (masquerade?.avatar) { + url = masquerade.avatar; + } else if (!url) { let override; if (target && showServerIdentity) { const { server } = useParams<{ server?: string }>(); diff --git a/src/components/common/user/UserShort.tsx b/src/components/common/user/UserShort.tsx index 405a40a9..1045550d 100644 --- a/src/components/common/user/UserShort.tsx +++ b/src/components/common/user/UserShort.tsx @@ -1,6 +1,8 @@ import { observer } from "mobx-react-lite"; import { useParams } from "react-router-dom"; +import { Masquerade } from "revolt-api/types/Channels"; import { User } from "revolt.js/dist/maps/Users"; +import { Nullable } from "revolt.js/dist/util/null"; import styled from "styled-components"; import { Text } from "preact-i18n"; @@ -29,16 +31,16 @@ const BotBadge = styled.div` type UsernameProps = JSX.HTMLAttributes & { user?: User; - override?: string; prefixAt?: boolean; + masquerade?: Masquerade; showServerIdentity?: boolean | "both"; }; export const Username = observer( ({ user, - override, prefixAt, + masquerade, showServerIdentity, ...otherProps }: UsernameProps) => { @@ -83,7 +85,7 @@ export const Username = observer( return ( <> - {override ?? username ?? ( + {masquerade?.name ?? username ?? ( )} @@ -97,7 +99,7 @@ export const Username = observer( return ( {prefixAt ? "@" : undefined} - {override ?? username ?? ( + {masquerade?.name ?? username ?? ( )} @@ -109,11 +111,13 @@ export default function UserShort({ user, size, prefixAt, + masquerade, showServerIdentity, }: { user?: User; size?: number; prefixAt?: boolean; + masquerade?: Masquerade; showServerIdentity?: boolean; }) { const { openScreen } = useIntermediate(); @@ -132,16 +136,18 @@ export default function UserShort({ return ( <> );