import { Flex, Padding, Position, Skeleton, Text, TouchableOpacity } from '@/@dble_layout'; import Avatar from '@/@widgets/image/Avatar'; import React, { memo } from 'react'; type Type = { users: { id?: string; avatarUrl: string; name: string; }[]; lastMessage: string; updatedAt: string; unreadCount?: number; isLoading?: boolean; onClick?: () => void; children?: never[]; }; // Memoize the ChatRoomCard component export const ChatRoomCard = memo(({ users, lastMessage, updatedAt, unreadCount, isLoading, onClick }: Type) => { const ChatRoomName = () => { if (users?.length === 1) { return ; } if (users?.length === 2) { return ( ); } return ( ); }; if (isLoading) return ( ); return ( {users?.length === 1 && } {users?.length === 2 && ( )} {users?.length === 3 && ( )} {users?.length > 3 && ( )} {lastMessage} {updatedAt} {unreadCount && unreadCount > 0 && ( {unreadCount > 99 ? '99+' : unreadCount} )} ); }); const Name = memo(({ name }: { name: string }) => { return ( {name} ); }); const AvatarWrapper = memo(({ children }: { children: React.ReactNode }) => { return ( {children} ); });