From 5e7f6b06fa4b97858a48b97267376175f312c15e Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Tue, 16 May 2023 14:41:23 -0500 Subject: [PATCH] add noProxy prop to user avatar --- .changeset/brave-mayflies-laugh.md | 5 +++++ src/components/profile-button.tsx | 12 +++++++++--- src/components/user-avatar.tsx | 15 +++++++++------ src/views/login/components/account-card.tsx | 2 +- src/views/user/components/header.tsx | 2 +- 5 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 .changeset/brave-mayflies-laugh.md diff --git a/.changeset/brave-mayflies-laugh.md b/.changeset/brave-mayflies-laugh.md new file mode 100644 index 000000000..98db919db --- /dev/null +++ b/.changeset/brave-mayflies-laugh.md @@ -0,0 +1,5 @@ +--- +"nostrudel": patch +--- + +Dont proxy main user profile image diff --git a/src/components/profile-button.tsx b/src/components/profile-button.tsx index cb7caaef6..ba9469f43 100644 --- a/src/components/profile-button.tsx +++ b/src/components/profile-button.tsx @@ -2,7 +2,7 @@ import { Box, LinkBox, Text } from "@chakra-ui/react"; import { Link } from "react-router-dom"; import { UserAvatar } from "./user-avatar"; import { useUserMetadata } from "../hooks/use-user-metadata"; -import { normalizeToBech32 } from "../helpers/nip19"; +import { Bech32Prefix, normalizeToBech32 } from "../helpers/nip19"; import { truncatedId } from "../helpers/nostr-event"; import { useCurrentAccount } from "../hooks/use-current-account"; @@ -11,8 +11,14 @@ export const ProfileButton = () => { const metadata = useUserMetadata(pubkey); return ( - - + + {metadata?.name} {truncatedId(normalizeToBech32(pubkey) ?? "")} diff --git a/src/components/user-avatar.tsx b/src/components/user-avatar.tsx index 816d87944..b9148e818 100644 --- a/src/components/user-avatar.tsx +++ b/src/components/user-avatar.tsx @@ -15,18 +15,21 @@ export const UserIdenticon = React.memo(({ pubkey }: { pubkey: string }) => { export type UserAvatarProps = Omit & { pubkey: string; + noProxy?: boolean; }; -export const UserAvatar = React.memo(({ pubkey, ...props }: UserAvatarProps) => { +export const UserAvatar = React.memo(({ pubkey, noProxy, ...props }: UserAvatarProps) => { const { imageProxy, proxyUserMedia } = useSubject(appSettings); const metadata = useUserMetadata(pubkey); const picture = useMemo(() => { if (metadata?.picture) { const src = safeUrl(metadata?.picture); - if (imageProxy && src) { - return new URL(`/96/${src}`, imageProxy).toString(); - } else if (proxyUserMedia) { - const last4 = String(pubkey).slice(pubkey.length - 4, pubkey.length); - return `https://media.nostr.band/thumbs/${last4}/${pubkey}-picture-64`; + if (!noProxy) { + if (imageProxy && src) { + return new URL(`/96/${src}`, imageProxy).toString(); + } else if (proxyUserMedia) { + const last4 = String(pubkey).slice(pubkey.length - 4, pubkey.length); + return `https://media.nostr.band/thumbs/${last4}/${pubkey}-picture-64`; + } } return src; } diff --git a/src/views/login/components/account-card.tsx b/src/views/login/components/account-card.tsx index eedcd113e..132e57af4 100644 --- a/src/views/login/components/account-card.tsx +++ b/src/views/login/components/account-card.tsx @@ -21,7 +21,7 @@ export default function AccountCard({ pubkey }: { pubkey: string }) { cursor="pointer" onClick={() => accountService.switchAccount(pubkey)} > - + {getUserDisplayName(metadata, pubkey)} diff --git a/src/views/user/components/header.tsx b/src/views/user/components/header.tsx index 4361ad546..e780c16b9 100644 --- a/src/views/user/components/header.tsx +++ b/src/views/user/components/header.tsx @@ -46,7 +46,7 @@ export default function Header({ pubkey }: { pubkey: string }) { return ( - +