import type { TwitterNotification } from "../lib/fetching/types"; import { timeAgo } from "../lib/utils/time"; interface ChatCardProps { notification: TwitterNotification; accent: string; } export function ChatCard({ notification, accent }: ChatCardProps) { const firstUser = Object.values(notification.users)[0]; const timestamp = timeAgo(Number(notification.timestampMs)); return (
{firstUser?.profile_image_url_https ? ( {firstUser.name} ) : ( {firstUser?.name?.[0] ?? "?"} )}
{firstUser?.name ?? "Notification"} {firstUser?.screen_name && @{firstUser.screen_name}} {timestamp}

{highlight(notification.message.text)}

); } function highlight(text: string) { const parts = text.split(/([@#][A-Za-z0-9_]+)/g); return parts.map((part, index) => { if (part.startsWith("@")) { return ( {part} ); } if (part.startsWith("#")) { return ( {part} ); } return {part}; }); }