From 61763d04c8ac2bfaf7652bfb02bdc7ac1922befa Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 21 Oct 2025 17:23:31 +0700 Subject: [PATCH] avoid unnecessary render --- src/components/dm/DMConversationList.tsx | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/components/dm/DMConversationList.tsx b/src/components/dm/DMConversationList.tsx index 292c25d..fbd885d 100644 --- a/src/components/dm/DMConversationList.tsx +++ b/src/components/dm/DMConversationList.tsx @@ -20,21 +20,23 @@ interface DMConversationListProps { onStatusClick?: () => void; } -const ConversationItem = memo(({ +interface ConversationItemProps { + pubkey: string; + isSelected: boolean; + onClick: () => void; + lastMessage: { decryptedContent?: string; error?: string } | null; + lastActivity: number; + hasNIP4Messages: boolean; +} + +const ConversationItemComponent = ({ pubkey, isSelected, onClick, lastMessage, lastActivity, hasNIP4Messages -}: { - pubkey: string; - isSelected: boolean; - onClick: () => void; - lastMessage: { decryptedContent?: string; error?: string } | null; - lastActivity: number; - hasNIP4Messages: boolean; -}) => { +}: ConversationItemProps) => { const author = useAuthor(pubkey); const metadata = author.data?.metadata; @@ -100,8 +102,9 @@ const ConversationItem = memo(({ ); -}); +}; +const ConversationItem = memo(ConversationItemComponent); ConversationItem.displayName = 'ConversationItem'; const ConversationListSkeleton = () => { @@ -230,7 +233,7 @@ export const DMConversationList = ({

No {activeTab} conversations

) : ( - +
{currentConversations.map((conversation) => (