mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 16:33:36 +00:00
avoid unnecessary render
This commit is contained in:
1 parent
211d303301
commit
61763d04c8
1 file changed
+14
-11
@@ -20,21 +20,23 @@ interface DMConversationListProps {
|
|||||||
onStatusClick?: () => void;
|
onStatusClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConversationItem = memo(({
|
interface ConversationItemProps {
|
||||||
pubkey,
|
|
||||||
isSelected,
|
|
||||||
onClick,
|
|
||||||
lastMessage,
|
|
||||||
lastActivity,
|
|
||||||
hasNIP4Messages
|
|
||||||
}: {
|
|
||||||
pubkey: string;
|
pubkey: string;
|
||||||
isSelected: boolean;
|
isSelected: boolean;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
lastMessage: { decryptedContent?: string; error?: string } | null;
|
lastMessage: { decryptedContent?: string; error?: string } | null;
|
||||||
lastActivity: number;
|
lastActivity: number;
|
||||||
hasNIP4Messages: boolean;
|
hasNIP4Messages: boolean;
|
||||||
}) => {
|
}
|
||||||
|
|
||||||
|
const ConversationItemComponent = ({
|
||||||
|
pubkey,
|
||||||
|
isSelected,
|
||||||
|
onClick,
|
||||||
|
lastMessage,
|
||||||
|
lastActivity,
|
||||||
|
hasNIP4Messages
|
||||||
|
}: ConversationItemProps) => {
|
||||||
const author = useAuthor(pubkey);
|
const author = useAuthor(pubkey);
|
||||||
const metadata = author.data?.metadata;
|
const metadata = author.data?.metadata;
|
||||||
|
|
||||||
@@ -100,8 +102,9 @@ const ConversationItem = memo(({
|
|||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
const ConversationItem = memo(ConversationItemComponent);
|
||||||
ConversationItem.displayName = 'ConversationItem';
|
ConversationItem.displayName = 'ConversationItem';
|
||||||
|
|
||||||
const ConversationListSkeleton = () => {
|
const ConversationListSkeleton = () => {
|
||||||
@@ -230,7 +233,7 @@ export const DMConversationList = ({
|
|||||||
<p className="text-sm">No {activeTab} conversations</p>
|
<p className="text-sm">No {activeTab} conversations</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<ScrollArea key={activeTab} className="h-full block">
|
<ScrollArea className="h-full block">
|
||||||
<div className="block w-full px-2 py-2 space-y-1">
|
<div className="block w-full px-2 py-2 space-y-1">
|
||||||
{currentConversations.map((conversation) => (
|
{currentConversations.map((conversation) => (
|
||||||
<ConversationItem
|
<ConversationItem
|
||||||
|
|||||||
Reference in new issue
Block a user