import { useState, useMemo, useEffect, useRef } from "react"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { Badge } from "@/components/ui/badge"; import { Progress } from "@/components/ui/progress"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; import { Image, Video, Film, FileText, ExternalLink, Repeat2, Download, FolderOpen, LayoutGrid, Grid3X3, List, StopCircle, Users, UserPlus, MessageSquare, Calendar, ArrowUp, ChevronLeft, ChevronRight, Eye, Heart, Bookmark, BadgeCheck, Maximize2, CheckCircle, XCircle, FileCheck, } from "lucide-react"; import { Spinner } from "@/components/ui/spinner"; import type { TimelineEntry, AccountInfo } from "@/types/api"; import { logger } from "@/lib/logger"; import { toastWithSound as toast } from "@/lib/toast-with-sound"; import { getSettings } from "@/lib/settings"; import { openExternal } from "@/lib/utils"; import { DownloadMediaWithMetadata, OpenFolder, IsFFmpegInstalled, ConvertGIFs, StopDownload, CheckFolderExists, CheckGifsFolderHasMP4 } from "../../wailsjs/go/main/App"; import { EventsOn, EventsOff } from "../../wailsjs/runtime/runtime"; import { main } from "../../wailsjs/go/models"; interface DownloadProgress { current: number; total: number; percent: number; } interface DownloadItemStatus { tweet_id: number; index: number; status: "success" | "failed" | "skipped"; } interface MediaListProps { accountInfo: AccountInfo; timeline: TimelineEntry[]; totalUrls: number; fetchedMediaType?: string; newMediaCount?: number | null; } function getThumbnailUrl(url: string): string { if (url.includes("video.twimg.com/tweet_video/")) { const match = url.match(/tweet_video\/([^\/]+)\.mp4/); if (match && match[1]) { const filename = match[1]; return `https://pbs.twimg.com/tweet_video_thumb/${filename}?format=jpg&name=360x360`; } } if (url.includes("pbs.twimg.com/media/")) { if (url.includes("?format=")) { if (url.includes("&name=")) { const parts = url.split("&name="); return parts[0] + "&name=360x360"; } return url + "&name=360x360"; } if (url.includes("?")) { return url + "&name=360x360"; } return url + "?format=jpg&name=360x360"; } return url; } function getPreviewUrl(url: string): string { if (url.includes("pbs.twimg.com/media/")) { if (url.includes("?format=")) { if (url.includes("&name=")) { const parts = url.split("&name="); return parts[0] + "&name=large"; } return url + "&name=large"; } if (url.includes("?")) { return url + "&name=large"; } return url + "?format=jpg&name=large"; } return url; } function getMediaIcon(type: string) { switch (type) { case "photo": return ; case "video": return