refactor event handler

This commit is contained in:
Ren Amamiya
2023-02-23 21:34:06 +07:00
parent 31a3a712ec
commit 4b73715927
9 changed files with 82 additions and 236 deletions
@@ -2,14 +2,14 @@
import { truncate } from '@utils/truncate';
import { useNostrEvents } from 'nostr-react';
import { useState } from 'react';
import { memo, useState } from 'react';
export default function RootUser({ userPubkey, action }: { userPubkey: string; action: string }) {
export const UserRepost = memo(function UserRepost({ pubkey }: { pubkey: string }) {
const [profile, setProfile] = useState({ picture: null, name: null });
const { onEvent } = useNostrEvents({
filter: {
authors: [userPubkey],
authors: [pubkey],
kinds: [0],
},
});
@@ -28,9 +28,7 @@ export default function RootUser({ userPubkey, action }: { userPubkey: string; a
return (
<div className="text-zinc-400">
<p>
{profile.name ? profile.name : truncate(userPubkey, 16, ' .... ')} {action}
</p>
<p>{profile.name ? profile.name : truncate(pubkey, 16, ' .... ')} repost</p>
</div>
);
}
});