diff --git a/src/components/note/base.tsx b/src/components/note/base.tsx index 13906701..06cd5a53 100644 --- a/src/components/note/base.tsx +++ b/src/components/note/base.tsx @@ -59,8 +59,10 @@ export const NoteBase = memo(function NoteBase({ event }: { event: any }) { }, [event.content, event.tags]); const getParent = useMemo(() => { - if (event.parent_id !== event.id && !event.content.includes('#[0]')) { - return ; + if (event.parent_id) { + if (event.parent_id !== event.id && !event.content.includes('#[0]')) { + return ; + } } return; diff --git a/src/components/profile/followers.tsx b/src/components/profile/followers.tsx index 31d3945a..db7eca53 100644 --- a/src/components/profile/followers.tsx +++ b/src/components/profile/followers.tsx @@ -1,4 +1,5 @@ import { RelayContext } from '@components/relaysProvider'; +import { UserFollow } from '@components/user/follow'; import { relaysAtom } from '@stores/relays'; @@ -19,8 +20,8 @@ export default function ProfileFollowers({ id }: { id: string }) { }, [id, pool, relays]); return ( -
- {followers && followers.map((follower, index) =>

{follower[1]}

)} +
+ {followers && followers.map((follower) => )}
); } diff --git a/src/components/profile/follows.tsx b/src/components/profile/follows.tsx index 38faa255..76ebd791 100644 --- a/src/components/profile/follows.tsx +++ b/src/components/profile/follows.tsx @@ -1,4 +1,5 @@ import { RelayContext } from '@components/relaysProvider'; +import { UserFollow } from '@components/user/follow'; import { relaysAtom } from '@stores/relays'; @@ -18,8 +19,8 @@ export default function ProfileFollows({ id }: { id: string }) { }, [id, pool, relays]); return ( -
- {follows && follows.map((follow, index) =>

{follow.pubkey}

)} +
+ {follows && follows.map((follow) => )}
); } diff --git a/src/components/profile/notes.tsx b/src/components/profile/notes.tsx index 1edb8d3f..11892f0d 100644 --- a/src/components/profile/notes.tsx +++ b/src/components/profile/notes.tsx @@ -1,4 +1,4 @@ -import { Content } from '@components/note/content'; +import { NoteBase } from '@components/note/base'; import { RelayContext } from '@components/relaysProvider'; import { relaysAtom } from '@stores/relays'; @@ -15,17 +15,14 @@ export default function ProfileNotes({ id }: { id: string }) { useEffect(() => { const user = new Author(pool, relays, id); - user.text((res) => setData((data) => [...data, res]), 0, 100); + user.text((res) => setData((data) => [...data, res]), 100, 0); }, [id, pool, relays]); return (
{data.map((item) => ( -
- +
+
))}
diff --git a/src/components/user/follow.tsx b/src/components/user/follow.tsx new file mode 100644 index 00000000..3eb92435 --- /dev/null +++ b/src/components/user/follow.tsx @@ -0,0 +1,45 @@ +import { ImageWithFallback } from '@components/imageWithFallback'; + +import { createCacheProfile } from '@utils/storage'; +import { truncate } from '@utils/truncate'; + +import { fetch } from '@tauri-apps/api/http'; +import destr from 'destr'; +import { memo, useCallback, useEffect, useState } from 'react'; + +export const UserFollow = memo(function UserFollow({ pubkey }: { pubkey: string }) { + const [profile, setProfile] = useState(null); + + const fetchProfile = useCallback(async (id: string) => { + const res = await fetch(`https://rbr.bio/${id}/metadata.json`, { + method: 'GET', + timeout: 30, + }); + return res.data; + }, []); + + useEffect(() => { + fetchProfile(pubkey) + .then((res: any) => { + setProfile(destr(res.content)); + createCacheProfile(res.pubkey, res.content); + }) + .catch(console.error); + }, [fetchProfile, pubkey]); + + return ( +
+
+ {profile?.picture && ( + + )} +
+
+ + {profile?.display_name || profile?.name} + + {truncate(pubkey, 16, ' .... ')} +
+
+ ); +});