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 ( +
+
+ } alt={id} className="h-8 w-8 rounded bg-zinc-900 object-cover" /> +
+
+
{metadata?.name || }
+

+ {metadata?.about || noteID.substring(0, 24) + '...' || } +

+
+
+ ); +}; diff --git a/src/components/layouts/newsfeed.tsx b/src/components/layouts/newsfeed.tsx index 357cb335..cc864ee4 100644 --- a/src/components/layouts/newsfeed.tsx +++ b/src/components/layouts/newsfeed.tsx @@ -20,9 +20,7 @@ export default function NewsfeedLayout({ children }: { children: React.ReactNode
-
-
{children}
-
+
{children}
diff --git a/src/pages/channel/index.page.tsx b/src/pages/channel/index.page.tsx index 59d47ebf..9454859b 100644 --- a/src/pages/channel/index.page.tsx +++ b/src/pages/channel/index.page.tsx @@ -1,4 +1,5 @@ import { AccountContext } from '@components/accountProvider'; +import { ChannelProfile } from '@components/channels/channelProfile'; import { FormChannel } from '@components/form/channel'; import NewsfeedLayout from '@components/layouts/newsfeed'; import { RelayContext } from '@components/relaysProvider'; @@ -9,6 +10,7 @@ import { MESSAGE_RELAYS } from '@stores/constants'; import { dateToUnix, hoursAgo } from '@utils/getDate'; import { usePageContext } from '@utils/hooks/usePageContext'; +import { EyeClose, MicMute } from 'iconoir-react'; import { useSetAtom } from 'jotai'; import { useResetAtom } from 'jotai/utils'; import { Suspense, lazy, useContext, useRef } from 'react'; @@ -77,12 +79,27 @@ export function Page() { return ( -
- Loading...

}> - -
-
- +
+
+
+ +
+
+
+ +
+
+ +
+
+
+
+ Loading...

}> + +
+
+ +
diff --git a/src/pages/chat/index.page.tsx b/src/pages/chat/index.page.tsx index 63b87d53..a87a4759 100644 --- a/src/pages/chat/index.page.tsx +++ b/src/pages/chat/index.page.tsx @@ -57,7 +57,7 @@ export function Page() { return ( -
+
Loading...

}>
diff --git a/src/pages/newsfeed/circle/index.page.tsx b/src/pages/newsfeed/circle/index.page.tsx index 2155c72e..d391822d 100644 --- a/src/pages/newsfeed/circle/index.page.tsx +++ b/src/pages/newsfeed/circle/index.page.tsx @@ -3,8 +3,12 @@ import NewsfeedLayout from '@components/layouts/newsfeed'; export function Page() { return ( -
-

Sorry, this feature under development, it will come in the next version

+
+
+

+ Sorry, this feature under development, it will come in the next version +

+
); diff --git a/src/pages/newsfeed/following/index.page.tsx b/src/pages/newsfeed/following/index.page.tsx index ef48d400..f4992c46 100644 --- a/src/pages/newsfeed/following/index.page.tsx +++ b/src/pages/newsfeed/following/index.page.tsx @@ -82,7 +82,7 @@ export function Page() { return ( -
+
{hasNewerNote && (