added kind 6 to newsfeed and changed useMetadata to useProfileMetadata

This commit is contained in:
Ren Amamiya
2023-04-16 16:43:17 +07:00
parent a7e95fd18a
commit 3aeb70f234
19 changed files with 297 additions and 83 deletions

View File

@@ -2,13 +2,13 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useMetadata } from '@utils/metadata';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import { memo } from 'react';
export const UserBase = memo(function UserBase({ pubkey }: { pubkey: string }) {
const profile = useMetadata(pubkey);
const profile = useProfileMetadata(pubkey);
return (
<div className="flex items-center gap-2">

View File

@@ -2,7 +2,7 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useMetadata } from '@utils/metadata';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import dayjs from 'dayjs';
@@ -12,7 +12,7 @@ import { MoreHoriz } from 'iconoir-react';
dayjs.extend(relativeTime);
export const UserExtend = ({ pubkey, time }: { pubkey: string; time: number }) => {
const profile = useMetadata(pubkey);
const profile = useProfileMetadata(pubkey);
return (
<div className="group flex items-start gap-2">

View File

@@ -2,11 +2,11 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useMetadata } from '@utils/metadata';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
export const UserFollow = ({ pubkey }: { pubkey: string }) => {
const profile = useMetadata(pubkey);
const profile = useProfileMetadata(pubkey);
return (
<div className="flex items-center gap-2">

View File

@@ -2,7 +2,7 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useMetadata } from '@utils/metadata';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import dayjs from 'dayjs';
@@ -12,7 +12,7 @@ import { MoreHoriz } from 'iconoir-react';
dayjs.extend(relativeTime);
export const UserLarge = ({ pubkey, time }: { pubkey: string; time: number }) => {
const profile = useMetadata(pubkey);
const profile = useProfileMetadata(pubkey);
return (
<div className="flex items-center gap-2">

View File

@@ -1,8 +1,8 @@
import { useMetadata } from '@utils/metadata';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
export const UserMention = ({ pubkey }: { pubkey: string }) => {
const profile = useMetadata(pubkey);
const profile = useProfileMetadata(pubkey);
return (
<span className="cursor-pointer text-fuchsia-500">
@{profile?.name || profile?.username || truncate(pubkey, 16, ' .... ')}

View File

@@ -2,11 +2,11 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useMetadata } from '@utils/metadata';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
export const UserMini = ({ pubkey }: { pubkey: string }) => {
const profile = useMetadata(pubkey);
const profile = useProfileMetadata(pubkey);
return (
<div className="group flex items-start gap-1">

View File

@@ -0,0 +1,35 @@
import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);
export const UserQuoteRepost = ({ pubkey, time }: { pubkey: string; time: number }) => {
const profile = useProfileMetadata(pubkey);
return (
<div className="group flex items-center gap-2">
<div className="relative h-11 w-11 shrink overflow-hidden rounded-md bg-white">
<ImageWithFallback
src={profile?.picture || DEFAULT_AVATAR}
alt={pubkey}
fill={true}
className="rounded-md object-cover"
/>
</div>
<div className="flex items-baseline gap-2 text-sm">
<h5 className="font-bold leading-tight group-hover:underline">
{profile?.display_name || profile?.name || truncate(pubkey, 16, ' .... ')} reposted
</h5>
<span className="leading-tight text-zinc-500">·</span>
<span className="text-zinc-500">{dayjs().to(dayjs.unix(time))}</span>
</div>
</div>
);
};