From 6685d9af382c5d305f0bee2357504390e8703547 Mon Sep 17 00:00:00 2001 From: reya Date: Sat, 28 Oct 2023 08:29:38 +0700 Subject: [PATCH] update user component --- src/shared/user.tsx | 139 ++++++++++++++++++++++++---------- src/utils/hooks/useProfile.ts | 3 +- 2 files changed, 103 insertions(+), 39 deletions(-) diff --git a/src/shared/user.tsx b/src/shared/user.tsx index 65b2f364..f9df835e 100644 --- a/src/shared/user.tsx +++ b/src/shared/user.tsx @@ -2,10 +2,7 @@ import * as Avatar from '@radix-ui/react-avatar'; import * as HoverCard from '@radix-ui/react-hover-card'; import { minidenticon } from 'minidenticons'; import { memo } from 'react'; -import ReactMarkdown from 'react-markdown'; import { Link } from 'react-router-dom'; -import rehypeExternalLinks from 'rehype-external-links'; -import remarkGfm from 'remark-gfm'; import { RepostIcon, WorldIcon } from '@shared/icons'; import { NIP05 } from '@shared/nip05'; @@ -46,39 +43,16 @@ export const User = memo(function User({ const svgURI = 'data:image/svg+xml;utf8,' + encodeURIComponent(minidenticon(pubkey, 90, 50)); - if (status === 'pending') { - if (variant === 'avatar') { + if (variant === 'mention') { + if (status === 'pending') { return ( -
- ); - } - - if (variant === 'mention' || variant === 'notify') { - return ( -
-
+
+
); } - if (variant === 'stacked') { - return ( -
- ); - } - - return ( -
-
-
-
-
-
- ); - } - - if (variant === 'mention') { return (
@@ -113,6 +87,15 @@ export const User = memo(function User({ } if (variant === 'notify') { + if (status === 'pending') { + return ( +
+
+
+
+ ); + } + return (
@@ -143,6 +126,19 @@ export const User = memo(function User({ } if (variant === 'large') { + if (status === 'pending') { + return ( +
+
+
+
+
+
+
+
+ ); + } + return (
@@ -167,15 +163,9 @@ export const User = memo(function User({

{user?.name || user?.display_name || user?.displayName}

- +

{user?.about || user?.bio || 'No bio'} - +

{user?.website ? ( @@ -195,6 +185,18 @@ export const User = memo(function User({ } if (variant === 'simple') { + if (status === 'pending') { + return ( +
+
+
+
+
+
+
+ ); + } + return (
@@ -227,6 +229,12 @@ export const User = memo(function User({ } if (variant === 'avatar') { + if (status === 'pending') { + return ( +
+ ); + } + return ( + ); + } + return ( + ); + } + return ( + ); + } + return ( +
+ +
+
+
+
+
+
+ ); + } + return (
@@ -353,6 +393,18 @@ export const User = memo(function User({ } if (variant === 'thread') { + if (status === 'pending') { + return ( +
+
+
+
+
+
+
+ ); + } + return (
@@ -386,6 +438,17 @@ export const User = memo(function User({ ); } + if (status === 'pending') { + return ( +
+
+
+
+
+
+ ); + } + return (
diff --git a/src/utils/hooks/useProfile.ts b/src/utils/hooks/useProfile.ts index b2fa2e7d..6f73237e 100644 --- a/src/utils/hooks/useProfile.ts +++ b/src/utils/hooks/useProfile.ts @@ -17,8 +17,9 @@ export function useProfile(pubkey: string, embed?: string) { return profile; } - const cleanPubkey = pubkey.replace('-', ''); + const cleanPubkey = pubkey.replace(/[^a-zA-Z0-9]/g, ''); const user = ndk.getUser({ hexpubkey: cleanPubkey }); + return await user.fetchProfile(); }, enabled: !!ndk,