From b84c0ff0d6b159294c92e1bf66c446dd43d20b53 Mon Sep 17 00:00:00 2001
From: Ren Amamiya <123083837+reyamir@users.noreply.github.com>
Date: Wed, 19 Apr 2023 09:33:46 +0700
Subject: [PATCH] added useChannelMetadata and support kind 41
---
src/components/channels/browseChannelItem.tsx | 12 +++--
src/utils/hooks/useChannelMetadata.tsx | 52 +++++++++++++++++++
src/utils/storage.tsx | 6 +++
3 files changed, 65 insertions(+), 5 deletions(-)
create mode 100644 src/utils/hooks/useChannelMetadata.tsx
diff --git a/src/components/channels/browseChannelItem.tsx b/src/components/channels/browseChannelItem.tsx
index 60b6e791..367f21f2 100644
--- a/src/components/channels/browseChannelItem.tsx
+++ b/src/components/channels/browseChannelItem.tsx
@@ -2,16 +2,18 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
+import { useChannelMetadata } from '@utils/hooks/useChannelMetadata';
+
import { useRouter } from 'next/navigation';
import { useCallback } from 'react';
export const BrowseChannelItem = ({ data }: { data: any }) => {
const router = useRouter();
- const channel = JSON.parse(data.content);
+ const channel = useChannelMetadata(data.event_id, data.metadata);
const openChannel = useCallback(
(id: string) => {
- router.push(`/channels/${id}`);
+ router.push(`/nostr/channels/${id}`);
},
[router]
);
@@ -23,15 +25,15 @@ export const BrowseChannelItem = ({ data }: { data: any }) => {
>
- {channel.name}
- {channel.about}
+ {channel?.name}
+ {channel?.about}