respect channel pubkey for kind 40, 41

This commit is contained in:
Ren Amamiya
2023-04-25 10:39:08 +07:00
parent 08d2625d36
commit 3aa71ab064
4 changed files with 23 additions and 20 deletions

View File

@@ -1,12 +1,11 @@
import { DEFAULT_AVATAR } from '@stores/constants';
import { useChannelMetadata } from '@utils/hooks/useChannelMetadata';
import { usePageContext } from '@utils/hooks/usePageContext';
import Skeleton from 'react-loading-skeleton';
import { twMerge } from 'tailwind-merge';
export const ChannelListItem = ({ data }: { data: any }) => {
const channel: any = useChannelMetadata(data.event_id);
const channel: any = useChannelMetadata(data.event_id, data.pubkey);
const pageContext = usePageContext();
const searchParams: any = pageContext.urlParsed.search;
@@ -14,17 +13,17 @@ export const ChannelListItem = ({ data }: { data: any }) => {
return (
<a
href={`/channel?id=${data.event_id}`}
href={`/channel?id=${data.event_id}&pubkey=${data.pubkey}`}
className={twMerge(
'inline-flex items-center gap-2 rounded-md px-2.5 py-1.5 hover:bg-zinc-900',
pageID === data.event_id ? 'dark:bg-zinc-900 dark:text-zinc-100 hover:dark:bg-zinc-800' : ''
)}
>
<div className="relative h-5 w-5 shrink-0 rounded bg-zinc-900">
<img src={channel?.picture || DEFAULT_AVATAR} alt={data.event_id} className="h-5 w-5 rounded object-contain" />
<img src={channel?.picture || <Skeleton />} alt={data.event_id} className="h-5 w-5 rounded object-contain" />
</div>
<div>
<h5 className="truncate text-sm font-medium text-zinc-400">{channel?.name}</h5>
<h5 className="truncate text-sm font-medium text-zinc-400">{channel?.name || <Skeleton />}</h5>
</div>
</a>
);

View File

@@ -4,8 +4,8 @@ import { Copy } from 'iconoir-react';
import { nip19 } from 'nostr-tools';
import Skeleton from 'react-loading-skeleton';
export const ChannelProfile = ({ id }: { id: string }) => {
const metadata = useChannelMetadata(id);
export const ChannelProfile = ({ id, pubkey }: { id: string; pubkey: string }) => {
const metadata = useChannelMetadata(id, pubkey);
const noteID = nip19.noteEncode(id);
const copyNoteID = async () => {