From 86468e75cb47f00465a4e639dbf6ae4c93836071 Mon Sep 17 00:00:00 2001 From: codytseng Date: Thu, 23 Jan 2025 11:01:49 +0800 Subject: [PATCH] feat: mentions --- src/components/Nip05/index.tsx | 8 +- .../PostEditor/NormalPostContent.tsx | 12 +- .../PostEditor/PicturePostContent.tsx | 12 +- src/components/ProfileCard/index.tsx | 4 +- .../TextareaWithMentions.tsx/index.tsx | 191 ++++++++++++++++++ .../TextareaWithMentions.tsx/utils.ts | 67 ++++++ src/components/UserItem/index.tsx | 5 +- src/pages/secondary/MuteListPage/index.tsx | 5 +- src/pages/secondary/ProfilePage/index.tsx | 4 +- 9 files changed, 280 insertions(+), 28 deletions(-) create mode 100644 src/components/TextareaWithMentions.tsx/index.tsx create mode 100644 src/components/TextareaWithMentions.tsx/utils.ts diff --git a/src/components/Nip05/index.tsx b/src/components/Nip05/index.tsx index c2f209bb..cc2a0367 100644 --- a/src/components/Nip05/index.tsx +++ b/src/components/Nip05/index.tsx @@ -1,8 +1,12 @@ +import { useFetchProfile } from '@/hooks' import { useFetchNip05 } from '@/hooks/useFetchNip05' import { BadgeAlert, BadgeCheck } from 'lucide-react' -export default function Nip05({ nip05, pubkey }: { nip05?: string; pubkey: string }) { - const { nip05IsVerified, nip05Name, nip05Domain } = useFetchNip05(nip05, pubkey) +export default function Nip05({ pubkey }: { pubkey: string }) { + const { profile } = useFetchProfile(pubkey) + const { nip05IsVerified, nip05Name, nip05Domain } = useFetchNip05(profile?.nip05, pubkey) + + if (!profile?.nip05) return null return ( nip05Name && diff --git a/src/components/PostEditor/NormalPostContent.tsx b/src/components/PostEditor/NormalPostContent.tsx index 8768a6e0..b94943da 100644 --- a/src/components/PostEditor/NormalPostContent.tsx +++ b/src/components/PostEditor/NormalPostContent.tsx @@ -1,7 +1,6 @@ import { Button } from '@/components/ui/button' import { Label } from '@/components/ui/label' import { Switch } from '@/components/ui/switch' -import { Textarea } from '@/components/ui/textarea' import { StorageKey } from '@/constants' import { useToast } from '@/hooks/use-toast' import { createCommentDraftEvent, createShortTextNoteDraftEvent } from '@/lib/draft-event' @@ -11,6 +10,7 @@ import { ChevronDown, ImageUp, LoaderCircle } from 'lucide-react' import { Event, kinds } from 'nostr-tools' import { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' +import TextareaWithMentions from '../TextareaWithMentions.tsx' import Mentions from './Mentions' import Preview from './Preview' import Uploader from './Uploader' @@ -39,10 +39,6 @@ export default function NormalPostContent({ setAddClientTag(window.localStorage.getItem(StorageKey.ADD_CLIENT_TAG) === 'true') }, []) - const handleTextareaChange = (e: React.ChangeEvent) => { - setContent(e.target.value) - } - const post = async (e: React.MouseEvent) => { e.stopPropagation() checkLogin(async () => { @@ -103,10 +99,10 @@ export default function NormalPostContent({ return (
-