From 53fd29ddb82c1eaf8ab340e8eb3ed76bd46d9c18 Mon Sep 17 00:00:00 2001 From: Ren Amamiya <123083837+reyamir@users.noreply.github.com> Date: Tue, 25 Apr 2023 09:33:17 +0700 Subject: [PATCH] update layout --- src/components/channels/channelListItem.tsx | 10 +---- src/components/channels/channelProfile.tsx | 23 ++++++++++ src/components/layouts/newsfeed.tsx | 4 +- src/pages/channel/index.page.tsx | 29 ++++++++++--- src/pages/chat/index.page.tsx | 2 +- src/pages/newsfeed/circle/index.page.tsx | 8 +++- src/pages/newsfeed/following/index.page.tsx | 2 +- src/utils/hooks/useChannelMetadata.tsx | 48 +++++++++++++++------ src/utils/storage.tsx | 7 +++ 9 files changed, 99 insertions(+), 34 deletions(-) create mode 100644 src/components/channels/channelProfile.tsx diff --git a/src/components/channels/channelListItem.tsx b/src/components/channels/channelListItem.tsx index 73c99d7d..86219c29 100644 --- a/src/components/channels/channelListItem.tsx +++ b/src/components/channels/channelListItem.tsx @@ -6,15 +6,7 @@ import { usePageContext } from '@utils/hooks/usePageContext'; import { twMerge } from 'tailwind-merge'; export const ChannelListItem = ({ data }: { data: any }) => { - let fallback: any; - - if (typeof data.metadata === 'object') { - fallback = data.metadata; - } else { - fallback = JSON.parse(data.metadata); - } - - const channel: any = useChannelMetadata(data.event_id, fallback); + const channel: any = useChannelMetadata(data.event_id); const pageContext = usePageContext(); const searchParams: any = pageContext.urlParsed.search; diff --git a/src/components/channels/channelProfile.tsx b/src/components/channels/channelProfile.tsx new file mode 100644 index 00000000..e8f43166 --- /dev/null +++ b/src/components/channels/channelProfile.tsx @@ -0,0 +1,23 @@ +import { useChannelMetadata } from '@utils/hooks/useChannelMetadata'; + +import { nip19 } from 'nostr-tools'; +import Skeleton from 'react-loading-skeleton'; + +export const ChannelProfile = ({ id }: { id: string }) => { + const metadata = useChannelMetadata(id); + const noteID = nip19.noteEncode(id); + + return ( +
+ {metadata?.about || noteID.substring(0, 24) + '...' ||
Sorry, this feature under development, it will come in the next version
++ Sorry, this feature under development, it will come in the next version +
+