This commit is contained in:
afkarxyz committed 2025-12-17 10:05:32 +07:00
1 parent b4266cb7fa
commit ada11f086e
24 files changed
+2006 -1828

No files matched your search

+599 -80
View File
@@ -34,9 +34,10 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Trash2, FileInput, FileOutput, Pencil, Tag, Shuffle, X, Download, StopCircle, Globe, Lock, Bookmark, Heart, Image, Images, Video, Film, FileText, Filter, AlertCircle, MoreVertical, FileBraces, CloudBackup } from "lucide-react";
import { Trash2, FileInput, FileOutput, Pencil, Tag, Shuffle, X, XCircle, Download, StopCircle, Globe, Lock, Bookmark, Heart, Image, Images, Video, Film, FileText, Filter, AlertCircle, MoreVertical, FileBraces, CloudBackup, Search, LayoutGrid, Grid3X3, List, ArrowUpDown, ArrowUp, FolderOpen } from "lucide-react";
import { toastWithSound as toast } from "@/lib/toast-with-sound";
import { getSettings } from "@/lib/settings";
import { openExternal } from "@/lib/utils";
import {
GetAllAccountsFromDB,
GetAccountFromDB,
@@ -48,6 +49,9 @@ import {
GetAllGroups,
DownloadMediaWithMetadata,
StopDownload,
CheckFolderExists,
OpenFolder,
GetFolderPath,
} from "../../wailsjs/go/main/App";
import { EventsOn, EventsOff } from "../../wailsjs/runtime/runtime";
import { main } from "../../wailsjs/go/models";
@@ -105,17 +109,22 @@ interface DatabaseViewProps {
onUpdateSelected?: (usernames: string[]) => void;
}
const ITEMS_PER_PAGE = 10;
const INITIAL_LOAD_COUNT = 12;
const LOAD_MORE_COUNT = 12;
export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewProps) {
const [accounts, setAccounts] = useState<AccountListItem[]>([]);
const [loading, setLoading] = useState(true);
const [selectedIds, setSelectedIds] = useState<Set<number>>(new Set());
const [currentPage, setCurrentPage] = useState(1);
const [visibleCount, setVisibleCount] = useState(INITIAL_LOAD_COUNT);
const [showScrollTop, setShowScrollTop] = useState(false);
const [groups, setGroups] = useState<GroupInfo[]>([]);
const [filterGroup, setFilterGroup] = useState<string>("all");
const [filterMediaType, setFilterMediaType] = useState<string>("all");
const [viewMode, setViewMode] = useState<"public" | "private">("public");
const [accountViewMode, setAccountViewMode] = useState<"public" | "private">("public");
const [searchQuery, setSearchQuery] = useState<string>("");
const [sortOrder, setSortOrder] = useState<"newest" | "oldest">("newest");
const [gridView, setGridView] = useState<"large" | "small" | "list">("list");
const [editingAccount, setEditingAccount] = useState<AccountListItem | null>(null);
const [editGroupName, setEditGroupName] = useState("");
const [editGroupColor, setEditGroupColor] = useState("");
@@ -127,6 +136,32 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
const [bulkDownloadCurrent, setBulkDownloadCurrent] = useState(0);
const [bulkDownloadTotal, setBulkDownloadTotal] = useState(0);
const stopBulkDownloadRef = useRef(false);
const loadMoreRef = useRef<HTMLDivElement>(null);
const [folderExistence, setFolderExistence] = useState<Map<number, boolean>>(new Map());
// Check folder existence for all accounts
const checkFolderExistence = async (accountsList: AccountListItem[]) => {
const settings = getSettings();
const basePath = settings.downloadPath;
if (!basePath) return;
const folderMap = new Map<number, boolean>();
for (const account of accountsList) {
// For bookmarks/likes, check special folder names
let folderName = account.username;
if (account.username === "bookmarks") {
folderName = "My Bookmarks";
} else if (account.username === "likes") {
folderName = "My Likes";
}
const exists = await CheckFolderExists(basePath, folderName);
folderMap.set(account.id, exists);
}
setFolderExistence(folderMap);
};
const loadAccounts = async () => {
setLoading(true);
@@ -137,6 +172,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
if (groupsData) {
setGroups(groupsData.map((g) => ({ name: g.name || "", color: g.color || "" })));
}
// Check folder existence for all accounts
if (data && data.length > 0) {
checkFolderExistence(data);
}
} catch (error) {
console.error("Failed to load accounts:", error);
toast.error("Failed to load accounts");
@@ -149,6 +188,22 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
loadAccounts();
}, []);
// Reset visible count when grid view or filters change
useEffect(() => {
setVisibleCount(INITIAL_LOAD_COUNT);
}, [gridView, searchQuery, filterGroup, filterMediaType, accountViewMode, sortOrder]);
// Listen for scroll to show/hide scroll-to-top button
// Listen for scroll to show/hide scroll-to-top button
useEffect(() => {
const handleScroll = () => {
setShowScrollTop(window.scrollY > 300);
};
window.addEventListener("scroll", handleScroll);
return () => window.removeEventListener("scroll", handleScroll);
}, []);
// Intersection Observer for lazy loading
// Listen for download progress events
useEffect(() => {
const unsubscribe = EventsOn("download-progress", (progress: DownloadProgress) => {
@@ -160,6 +215,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
};
}, []);
const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: "smooth" });
};
// Separate accounts into public and private
const isPrivateAccount = (username: string) =>
username === "bookmarks" || username === "likes";
@@ -167,26 +226,61 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
const publicAccounts = accounts.filter((acc) => !isPrivateAccount(acc.username));
const privateAccounts = accounts.filter((acc) => isPrivateAccount(acc.username));
const baseAccounts = viewMode === "public" ? publicAccounts : privateAccounts;
const baseAccounts = accountViewMode === "public" ? publicAccounts : privateAccounts;
const filteredAccounts = baseAccounts.filter((acc) => {
// Filter by group
if (filterGroup !== "all") {
if (filterGroup === "ungrouped" && acc.group_name) return false;
if (filterGroup !== "ungrouped" && acc.group_name !== filterGroup) return false;
}
// Filter by media type
if (filterMediaType !== "all") {
const accMediaType = acc.media_type || "all";
// "all-media" in filter matches "all" in database (fetched with All Media option)
if (filterMediaType === "all-media") {
if (accMediaType !== "all") return false;
} else {
if (accMediaType !== filterMediaType) return false;
const filteredAccounts = baseAccounts
.filter((acc) => {
// Filter by search query
if (searchQuery) {
const query = searchQuery.toLowerCase();
const matchesUsername = acc.username.toLowerCase().includes(query);
const matchesName = acc.name.toLowerCase().includes(query);
if (!matchesUsername && !matchesName) return false;
}
}
return true;
});
// Filter by group
if (filterGroup !== "all") {
if (filterGroup === "ungrouped" && acc.group_name) return false;
if (filterGroup !== "ungrouped" && acc.group_name !== filterGroup) return false;
}
// Filter by media type
if (filterMediaType !== "all") {
const accMediaType = acc.media_type || "all";
// "all-media" in filter matches "all" in database (fetched with All Media option)
if (filterMediaType === "all-media") {
if (accMediaType !== "all") return false;
} else {
if (accMediaType !== filterMediaType) return false;
}
}
return true;
})
.sort((a, b) => {
// Sort by last_fetched date
const dateA = new Date(a.last_fetched).getTime();
const dateB = new Date(b.last_fetched).getTime();
return sortOrder === "newest" ? dateB - dateA : dateA - dateB;
});
// Intersection Observer for lazy loading
useEffect(() => {
const currentRef = loadMoreRef.current;
if (!currentRef) return;
const observer = new IntersectionObserver(
(entries) => {
if (entries[0].isIntersecting) {
setVisibleCount((prev) => prev + LOAD_MORE_COUNT);
}
},
{ threshold: 0.1, rootMargin: "100px" }
);
observer.observe(currentRef);
return () => {
observer.unobserve(currentRef);
};
}, [filteredAccounts.length, visibleCount, loading]);
const handleEditGroup = (account: AccountListItem) => {
setEditingAccount(account);
@@ -225,6 +319,22 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
}
};
const handleOpenFolder = async (username: string) => {
const settings = getSettings();
let folderName = username;
if (username === "bookmarks") {
folderName = "My Bookmarks";
} else if (username === "likes") {
folderName = "My Likes";
}
const folderPath = await GetFolderPath(settings.downloadPath, folderName);
try {
await OpenFolder(folderPath);
} catch (error) {
toast.error("Failed to open folder");
}
};
const handleDownload = async (id: number, username: string) => {
try {
const responseJSON = await GetAccountFromDB(id);
@@ -485,7 +595,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
try {
await ExportAccountsTXT(idsToExport, outputDir);
toast.success(`Exported ${idsToExport.length} account(s) to ${outputDir}\\twitterxmediabatchdownloader_backups\\twitterxmediabatchdownloader_multiple.txt`);
toast.success(`Exported ${formatNumberWithComma(idsToExport.length)} account(s) to ${outputDir}\\twitterxmediabatchdownloader_backups\\twitterxmediabatchdownloader_multiple.txt`);
} catch (error) {
toast.error("Failed to export");
}
@@ -627,27 +737,27 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
<div className="flex gap-0.5 p-0.5 bg-muted rounded-lg">
<button
type="button"
onClick={() => setViewMode("public")}
onClick={() => setAccountViewMode("public")}
className={`flex items-center gap-1 px-2 py-1 rounded-md text-xs font-medium transition-all ${
viewMode === "public"
accountViewMode === "public"
? "bg-background text-foreground shadow-sm"
: "text-muted-foreground hover:text-foreground"
}`}
>
<Globe className="h-3 w-3" />
Public ({publicAccounts.length})
Public ({formatNumberWithComma(publicAccounts.length)})
</button>
<button
type="button"
onClick={() => setViewMode("private")}
onClick={() => setAccountViewMode("private")}
className={`flex items-center gap-1 px-2 py-1 rounded-md text-xs font-medium transition-all ${
viewMode === "private"
accountViewMode === "private"
? "bg-background text-foreground shadow-sm"
: "text-muted-foreground hover:text-foreground"
}`}
>
<Lock className="h-3 w-3" />
Private ({privateAccounts.length})
Private ({formatNumberWithComma(privateAccounts.length)})
</button>
</div>
</div>
@@ -669,7 +779,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
</Button>
</DropdownMenuTrigger>
</TooltipTrigger>
<TooltipContent>Export Selected ({selectedIds.size})</TooltipContent>
<TooltipContent>Export Selected ({formatNumberWithComma(selectedIds.size)})</TooltipContent>
</Tooltip>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={handleExportJSON}>
@@ -707,7 +817,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
if (onUpdateSelected) {
onUpdateSelected(usernames);
toast.success(`Added ${usernames.length} account(s) to multiple fetch`);
toast.success(`Added ${formatNumberWithComma(usernames.length)} account(s) to multiple fetch`);
}
}}
disabled={selectedIds.size === 0 || hasPrivateAccountSelected()}
@@ -715,7 +825,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
<CloudBackup className="h-4 w-4" />
</Button>
</TooltipTrigger>
<TooltipContent>Update Selected ({selectedIds.size})</TooltipContent>
<TooltipContent>Update Selected ({formatNumberWithComma(selectedIds.size)})</TooltipContent>
</Tooltip>
{isBulkDownloading ? (
<Tooltip>
@@ -733,19 +843,19 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
<Download className="h-4 w-4" />
</Button>
</TooltipTrigger>
<TooltipContent>Download Selected ({selectedIds.size})</TooltipContent>
<TooltipContent>Download Selected ({formatNumberWithComma(selectedIds.size)})</TooltipContent>
</Tooltip>
)}
<Dialog open={clearAllDialogOpen} onOpenChange={setClearAllDialogOpen}>
<Tooltip>
<TooltipTrigger asChild>
<DialogTrigger asChild>
<Button variant="destructive" size="icon" disabled={baseAccounts.length === 0}>
<Button variant="destructive" size="icon" disabled={selectedIds.size === 0}>
<Trash2 className="h-4 w-4" />
</Button>
</DialogTrigger>
</TooltipTrigger>
<TooltipContent>Clear All {viewMode === "public" ? "Public" : "Private"}</TooltipContent>
<TooltipContent>Delete Selected ({formatNumberWithComma(selectedIds.size)})</TooltipContent>
</Tooltip>
<DialogContent className="[&>button]:hidden">
<div className="absolute right-4 top-4">
@@ -759,9 +869,9 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
</Button>
</div>
<DialogHeader>
<DialogTitle>Clear All {viewMode === "public" ? "Public" : "Private"} Accounts?</DialogTitle>
<DialogTitle>Delete {formatNumberWithComma(selectedIds.size)} Selected Account{selectedIds.size !== 1 ? 's' : ''}?</DialogTitle>
<DialogDescription>
This will permanently delete all {formatNumberWithComma(baseAccounts.length)} {viewMode === "public" ? "public" : "private"} saved accounts. This action cannot be undone.
This will permanently delete the selected account{selectedIds.size !== 1 ? 's' : ''}. This action cannot be undone.
</DialogDescription>
</DialogHeader>
<DialogFooter>
@@ -769,20 +879,20 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
variant="destructive"
onClick={async () => {
try {
// Delete only accounts matching the current view mode
const accountsToDelete = baseAccounts.map((acc) => acc.id);
for (const id of accountsToDelete) {
const idsToDelete = Array.from(selectedIds);
for (const id of idsToDelete) {
await DeleteAccountFromDB(id);
}
toast.success(`All ${viewMode === "public" ? "public" : "private"} accounts deleted`);
toast.success(`Deleted ${formatNumberWithComma(idsToDelete.length)} account${idsToDelete.length !== 1 ? 's' : ''}`);
setClearAllDialogOpen(false);
setSelectedIds(new Set());
loadAccounts();
} catch (error) {
toast.error("Failed to clear accounts");
toast.error("Failed to delete accounts");
}
}}
>
Delete All {viewMode === "public" ? "Public" : "Private"}
Delete {formatNumberWithComma(selectedIds.size)} Account{selectedIds.size !== 1 ? 's' : ''}
</Button>
</DialogFooter>
</DialogContent>
@@ -798,8 +908,8 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
</div>
) : (
<div className="space-y-2">
{/* Filter and Select All */}
<div className="flex items-center gap-4 px-4 py-2">
{/* Row 1: Select All + Search Bar (Search only for public) */}
<div className="flex items-center gap-4 py-2">
<div className="flex items-center gap-2">
<Checkbox
checked={selectedIds.size === filteredAccounts.length && filteredAccounts.length > 0}
@@ -809,7 +919,47 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
Select all {selectedIds.size > 0 && `(${formatNumberWithComma(selectedIds.size)} selected)`}
</span>
</div>
<div className="flex-1" />
{/* Search Bar - Only show for public accounts */}
{accountViewMode === "public" && (
<div className="relative flex-1">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
<Input
placeholder="Search..."
value={searchQuery}
onChange={(e) => {
setSearchQuery(e.target.value);
}}
className="pl-9 h-9"
/>
{searchQuery && (
<button
type="button"
onClick={() => {
setSearchQuery("");
}}
className="absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
>
<XCircle className="h-4 w-4" />
</button>
)}
</div>
)}
</div>
{/* Row 2: Sort, Filters, View Toggle */}
<div className="flex items-center gap-2 pb-2">
{/* Sort Order */}
<Select value={sortOrder} onValueChange={(v) => setSortOrder(v as "newest" | "oldest")}>
<SelectTrigger className="w-auto">
<ArrowUpDown className="h-4 w-4 mr-2" />
<SelectValue placeholder="Sort" />
</SelectTrigger>
<SelectContent>
<SelectItem value="newest">Newest</SelectItem>
<SelectItem value="oldest">Oldest</SelectItem>
</SelectContent>
</Select>
{/* Media Type Filter */}
<Select value={filterMediaType} onValueChange={setFilterMediaType}>
@@ -830,32 +980,32 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
<SelectItem value="image">
<span className="flex items-center gap-2">
<Image className="h-4 w-4 text-blue-500" />
Images Only
Images
</span>
</SelectItem>
<SelectItem value="video">
<span className="flex items-center gap-2">
<Video className="h-4 w-4 text-purple-500" />
Videos Only
Videos
</span>
</SelectItem>
<SelectItem value="gif">
<span className="flex items-center gap-2">
<Film className="h-4 w-4 text-green-500" />
GIFs Only
GIFs
</span>
</SelectItem>
<SelectItem value="text">
<span className="flex items-center gap-2">
<FileText className="h-4 w-4 text-orange-500" />
Text Only
Text
</span>
</SelectItem>
</SelectContent>
</Select>
{/* Group Filter */}
<Select value={filterGroup} onValueChange={setFilterGroup}>
<Select value={filterGroup} onValueChange={setFilterGroup} disabled={groups.length === 0}>
<SelectTrigger className="w-auto">
<Tag className="h-4 w-4 mr-2" />
<SelectValue placeholder="Filter by group" />
@@ -876,6 +1026,36 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
))}
</SelectContent>
</Select>
<div className="flex-1" />
{/* Grid View Toggle */}
<div className="flex items-center border rounded-md">
<Button
variant={gridView === "large" ? "secondary" : "ghost"}
size="icon"
className="h-9 w-9 rounded-r-none"
onClick={() => setGridView("large")}
>
<LayoutGrid className="h-4 w-4" />
</Button>
<Button
variant={gridView === "small" ? "secondary" : "ghost"}
size="icon"
className="h-9 w-9 rounded-none border-x"
onClick={() => setGridView("small")}
>
<Grid3X3 className="h-4 w-4" />
</Button>
<Button
variant={gridView === "list" ? "secondary" : "ghost"}
size="icon"
className="h-9 w-9 rounded-l-none"
onClick={() => setGridView("list")}
>
<List className="h-4 w-4" />
</Button>
</div>
</div>
{/* Bulk Download Progress */}
@@ -891,8 +1071,333 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
</div>
)}
{filteredAccounts
.slice((currentPage - 1) * ITEMS_PER_PAGE, currentPage * ITEMS_PER_PAGE)
{/* Grid View: Large */}
{gridView === "large" && (
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
{filteredAccounts
.slice(0, visibleCount)
.map((account) => (
<div
key={account.id}
className={`relative rounded-lg border transition-colors p-4 ${
selectedIds.has(account.id) ? "border-primary bg-primary/5" : "bg-card hover:bg-muted/50"
}`}
>
{/* Checkbox - Top Left */}
<Checkbox
checked={selectedIds.has(account.id)}
onCheckedChange={() => toggleSelect(account.id)}
className="absolute top-2 left-2 z-10"
/>
{/* Media Type Badge - Top Right */}
<div className="absolute top-2 right-2 z-10 flex gap-1">
<Badge
variant="secondary"
className={cn(
"text-xs flex items-center gap-1",
account.media_type === "text" && "bg-orange-500/20 text-orange-600 dark:text-orange-400",
account.media_type === "image" && "bg-blue-500/20 text-blue-600 dark:text-blue-400",
account.media_type === "video" && "bg-purple-500/20 text-purple-600 dark:text-purple-400",
account.media_type === "gif" && "bg-green-500/20 text-green-600 dark:text-green-400",
(!account.media_type || account.media_type === "all") && "bg-indigo-500/20 text-indigo-600 dark:text-indigo-400"
)}
>
{account.media_type === "text" ? <FileText className="h-3 w-3" /> :
account.media_type === "image" ? <Image className="h-3 w-3" /> :
account.media_type === "video" ? <Video className="h-3 w-3" /> :
account.media_type === "gif" ? <Film className="h-3 w-3" /> :
<Images className="h-3 w-3" />}
</Badge>
{!account.completed && (
<Badge variant="secondary" className="text-xs bg-yellow-500/20 text-yellow-600 dark:text-yellow-400">
<AlertCircle className="h-3 w-3" />
</Badge>
)}
</div>
<div className="flex flex-col items-center text-center gap-3 pt-4">
{isPrivateAccount(account.username) ? (
<div
className="w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center cursor-pointer hover:bg-primary/20 transition-colors"
onClick={() => handleView(account.id, account.username)}
>
{account.username === "bookmarks" ? (
<Bookmark className="h-10 w-10 text-primary" />
) : (
<Heart className="h-10 w-10 text-primary" />
)}
</div>
) : (
<img
src={account.profile_image}
alt={account.name}
className="w-20 h-20 rounded-full cursor-pointer hover:opacity-80 transition-opacity"
onClick={() => handleView(account.id, account.username)}
/>
)}
<div className="w-full min-w-0">
<div className="font-medium truncate">{account.name}</div>
{!isPrivateAccount(account.username) && (
<button
type="button"
onClick={() => openExternal(`https://x.com/${account.username}`)}
className="text-sm text-muted-foreground hover:text-primary hover:underline"
>
@{account.username}
</button>
)}
<div className="text-sm text-muted-foreground mt-1">
{formatNumberWithComma(account.total_media)}
</div>
</div>
<div className="flex gap-1">
{downloadingAccountId === account.id ? (
<Button
variant="outline"
size="icon"
className="h-8 w-8"
onClick={handleStopDownload}
>
<StopCircle className="h-4 w-4 text-destructive" />
</Button>
) : (
<Button
variant="default"
size="icon"
className="h-8 w-8"
onClick={() => handleDownload(account.id, account.username)}
disabled={isDownloading}
>
<Download className="h-4 w-4" />
</Button>
)}
<Button
variant="outline"
size="icon"
className="h-8 w-8"
onClick={() => handleOpenFolder(account.username)}
disabled={!folderExistence.get(account.id)}
>
<FolderOpen className="h-4 w-4" />
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" size="icon" className="h-8 w-8">
<MoreVertical className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => handleEditGroup(account)}>
<Pencil className="h-4 w-4 mr-2" />
Edit Group
</DropdownMenuItem>
<DropdownMenuItem
onClick={async () => {
const settings = getSettings();
const outputDir = settings.downloadPath || "";
try {
await ExportAccountJSON(account.id, outputDir);
toast.success(`Exported @${account.username}`);
} catch (error) {
toast.error("Failed to export");
}
}}
>
<FileOutput className="h-4 w-4 mr-2" />
Export JSON
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => handleDelete(account.id, account.username)}
className="text-destructive focus:text-destructive"
>
<Trash2 className="h-4 w-4 mr-2" />
Delete
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
{/* Progress bar */}
{downloadingAccountId === account.id && downloadProgress && (
<div className="mt-3 space-y-1">
<div className="flex items-center justify-between text-xs">
<span className="text-muted-foreground">
{downloadProgress.current}/{downloadProgress.total}
</span>
<span className="font-medium">{downloadProgress.percent}%</span>
</div>
<Progress value={downloadProgress.percent} className="h-1.5" />
</div>
)}
</div>
))}
</div>
)}
{/* Grid View: Small */}
{gridView === "small" && (
<div className="grid grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-3">
{filteredAccounts
.slice(0, visibleCount)
.map((account) => (
<div
key={account.id}
className={`relative rounded-lg border transition-colors p-3 ${
selectedIds.has(account.id) ? "border-primary bg-primary/5" : "bg-card hover:bg-muted/50"
}`}
>
{/* Checkbox - Top Left */}
<Checkbox
checked={selectedIds.has(account.id)}
onCheckedChange={() => toggleSelect(account.id)}
className="absolute top-1.5 left-1.5 z-10"
/>
{/* Media Type Badge & Incomplete - Top Right */}
<div className="absolute top-1.5 right-1.5 z-10 flex gap-1">
<Badge
variant="secondary"
className={cn(
"text-xs p-1",
account.media_type === "text" && "bg-orange-500/20 text-orange-600 dark:text-orange-400",
account.media_type === "image" && "bg-blue-500/20 text-blue-600 dark:text-blue-400",
account.media_type === "video" && "bg-purple-500/20 text-purple-600 dark:text-purple-400",
account.media_type === "gif" && "bg-green-500/20 text-green-600 dark:text-green-400",
(!account.media_type || account.media_type === "all") && "bg-indigo-500/20 text-indigo-600 dark:text-indigo-400"
)}
>
{account.media_type === "text" ? <FileText className="h-3 w-3" /> :
account.media_type === "image" ? <Image className="h-3 w-3" /> :
account.media_type === "video" ? <Video className="h-3 w-3" /> :
account.media_type === "gif" ? <Film className="h-3 w-3" /> :
<Images className="h-3 w-3" />}
</Badge>
{!account.completed && (
<Badge variant="secondary" className="text-xs p-1 bg-yellow-500/20 text-yellow-600 dark:text-yellow-400">
<AlertCircle className="h-3 w-3" />
</Badge>
)}
</div>
<div className="flex flex-col items-center text-center gap-2 pt-4">
{isPrivateAccount(account.username) ? (
<div
className="w-14 h-14 rounded-full bg-primary/10 flex items-center justify-center cursor-pointer hover:bg-primary/20 transition-colors"
onClick={() => handleView(account.id, account.username)}
>
{account.username === "bookmarks" ? (
<Bookmark className="h-7 w-7 text-primary" />
) : (
<Heart className="h-7 w-7 text-primary" />
)}
</div>
) : (
<img
src={account.profile_image}
alt={account.name}
className="w-14 h-14 rounded-full cursor-pointer hover:opacity-80 transition-opacity"
onClick={() => handleView(account.id, account.username)}
/>
)}
<div className="w-full min-w-0">
<div className="text-xs font-medium truncate">{account.name}</div>
{!isPrivateAccount(account.username) && (
<button
type="button"
onClick={() => openExternal(`https://x.com/${account.username}`)}
className="text-xs text-muted-foreground hover:text-primary hover:underline truncate block w-full"
>
@{account.username}
</button>
)}
<div className="text-xs text-muted-foreground">
{formatNumberWithComma(account.total_media)}
</div>
</div>
<div className="flex gap-1">
{downloadingAccountId === account.id ? (
<Button
variant="outline"
size="icon"
className="h-7 w-7"
onClick={handleStopDownload}
>
<StopCircle className="h-3 w-3 text-destructive" />
</Button>
) : (
<Button
variant="default"
size="icon"
className="h-7 w-7"
onClick={() => handleDownload(account.id, account.username)}
disabled={isDownloading}
>
<Download className="h-3 w-3" />
</Button>
)}
<Button
variant="outline"
size="icon"
className="h-7 w-7"
onClick={() => handleOpenFolder(account.username)}
disabled={!folderExistence.get(account.id)}
>
<FolderOpen className="h-3 w-3" />
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" size="icon" className="h-7 w-7">
<MoreVertical className="h-3 w-3" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => handleEditGroup(account)}>
<Pencil className="h-4 w-4 mr-2" />
Edit Group
</DropdownMenuItem>
<DropdownMenuItem
onClick={async () => {
const settings = getSettings();
const outputDir = settings.downloadPath || "";
try {
await ExportAccountJSON(account.id, outputDir);
toast.success(`Exported @${account.username}`);
} catch (error) {
toast.error("Failed to export");
}
}}
>
<FileOutput className="h-4 w-4 mr-2" />
Export JSON
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => handleDelete(account.id, account.username)}
className="text-destructive focus:text-destructive"
>
<Trash2 className="h-4 w-4 mr-2" />
Delete
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
{/* Progress bar */}
{downloadingAccountId === account.id && downloadProgress && (
<div className="mt-2 space-y-1">
<div className="flex items-center justify-between text-xs">
<span className="text-muted-foreground">
{downloadProgress.current}/{downloadProgress.total}
</span>
<span className="font-medium">{downloadProgress.percent}%</span>
</div>
<Progress value={downloadProgress.percent} className="h-1" />
</div>
)}
</div>
))}
</div>
)}
{/* List View */}
{gridView === "list" && filteredAccounts
.slice(0, visibleCount)
.map((account, index) => (
<div
key={account.id}
@@ -906,7 +1411,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
onCheckedChange={() => toggleSelect(account.id)}
/>
<span className="text-sm text-muted-foreground w-8 text-center shrink-0">
{(currentPage - 1) * ITEMS_PER_PAGE + index + 1}
{index + 1}
</span>
{isPrivateAccount(account.username) ? (
<div
@@ -943,7 +1448,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
(!account.media_type || account.media_type === "all") && "bg-indigo-500/20 text-indigo-600 dark:text-indigo-400"
)}
>
{account.media_type === "text" ? <><FileText className="h-3 w-3" /> Text Only</> :
{account.media_type === "text" ? <><FileText className="h-3 w-3" /> Text</> :
account.media_type === "image" ? <><Image className="h-3 w-3" /> Images</> :
account.media_type === "video" ? <><Video className="h-3 w-3" /> Videos</> :
account.media_type === "gif" ? <><Film className="h-3 w-3" /> GIFs</> :
@@ -969,7 +1474,13 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
)}
</div>
{!isPrivateAccount(account.username) && (
<div className="text-sm text-muted-foreground">@{account.username}</div>
<button
type="button"
onClick={() => openExternal(`https://x.com/${account.username}`)}
className="text-sm text-muted-foreground hover:text-primary hover:underline"
>
@{account.username}
</button>
)}
<div className="text-sm text-muted-foreground">
{account.last_fetched} {getRelativeTime(account.last_fetched)}
@@ -1008,6 +1519,19 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
<TooltipContent>Download All Media</TooltipContent>
</Tooltip>
)}
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="outline"
size="icon"
onClick={() => handleOpenFolder(account.username)}
disabled={!folderExistence.get(account.id)}
>
<FolderOpen className="h-4 w-4" />
</Button>
</TooltipTrigger>
<TooltipContent>Open Folder</TooltipContent>
</Tooltip>
<DropdownMenu>
<Tooltip>
<TooltipTrigger asChild>
@@ -1094,33 +1618,28 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
</div>
))}
{/* Pagination */}
{filteredAccounts.length > ITEMS_PER_PAGE && (
<div className="flex items-center justify-center gap-2 pt-4">
<Button
variant="outline"
size="sm"
onClick={() => setCurrentPage((p) => Math.max(1, p - 1))}
disabled={currentPage === 1}
>
Previous
</Button>
<span className="text-sm text-muted-foreground px-4">
Page {currentPage} of {Math.ceil(filteredAccounts.length / ITEMS_PER_PAGE)}
</span>
<Button
variant="outline"
size="sm"
onClick={() => setCurrentPage((p) => Math.min(Math.ceil(filteredAccounts.length / ITEMS_PER_PAGE), p + 1))}
disabled={currentPage === Math.ceil(filteredAccounts.length / ITEMS_PER_PAGE)}
>
Next
</Button>
</div>
)}
{/* Load More Trigger (invisible) */}
<div
ref={loadMoreRef}
className={`h-4 ${visibleCount >= filteredAccounts.length ? 'hidden' : ''}`}
/>
</div>
)}
{/* Scroll to Top Button */}
{showScrollTop && (
<Button
variant="default"
size="icon"
className="fixed bottom-6 left-1/2 -translate-x-1/2 h-9 w-9 rounded-full shadow-lg z-30"
onClick={scrollToTop}
>
<ArrowUp className="h-4 w-4" />
</Button>
)}
{/* Edit Group Dialog */}
<Dialog open={!!editingAccount} onOpenChange={(open) => !open && setEditingAccount(null)}>
<DialogContent className="[&>button]:hidden">
+92 -50
View File
@@ -51,7 +51,7 @@ 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 } from "../../wailsjs/go/main/App";
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";
@@ -231,9 +231,10 @@ export function MediaList({
const [downloadProgress, setDownloadProgress] = useState<DownloadProgress | null>(null);
const [hasDownloaded, setHasDownloaded] = useState(false);
const [isConverting, setIsConverting] = useState(false);
const [hasGifs, setHasGifs] = useState(false);
const [ffmpegInstalled, setFfmpegInstalled] = useState(false);
const [showScrollTop, setShowScrollTop] = useState(false);
const [folderExists, setFolderExists] = useState(false);
const [gifsFolderHasMP4, setGifsFolderHasMP4] = useState(false);
const [previewIndex, setPreviewIndex] = useState<number | null>(null);
// Download status tracking per item (by tweet_id + index for uniqueness)
const [downloadedItems, setDownloadedItems] = useState<Set<string>>(new Set());
@@ -290,6 +291,40 @@ export function MediaList({
setVisibleCount(10);
}, [filteredTimeline.length]);
// Check folder existence and FFmpeg installation
useEffect(() => {
const checkFoldersAndFFmpeg = async () => {
const settings = getSettings();
const basePath = settings.downloadPath;
// Check FFmpeg installation
const installed = await IsFFmpegInstalled();
setFfmpegInstalled(installed);
if (!basePath || !accountInfo.name) return;
// For bookmarks/likes, check special folder names
let folderName = accountInfo.name;
if (accountInfo.nick === "My Bookmarks" || accountInfo.name === "bookmarks") {
folderName = "My Bookmarks";
} else if (accountInfo.nick === "My Likes" || accountInfo.name === "likes") {
folderName = "My Likes";
}
const exists = await CheckFolderExists(basePath, folderName);
setFolderExists(exists);
if (exists) {
const hasMP4 = await CheckGifsFolderHasMP4(basePath, folderName);
setGifsFolderHasMP4(hasMP4);
} else {
setGifsFolderHasMP4(false);
}
};
checkFoldersAndFFmpeg();
}, [accountInfo.name, accountInfo.nick, hasDownloaded]);
// Intersection Observer for lazy loading thumbnails
useEffect(() => {
if (!loadMoreRef.current) return;
@@ -538,13 +573,9 @@ export function MediaList({
}
setHasDownloaded(true);
// Check if there are GIFs and FFmpeg is installed
const hasGifItems = itemsWithIndices.some(({ item }) => item.type === "gif" || item.type === "animated_gif");
if (hasGifItems) {
setHasGifs(true);
const installed = await IsFFmpegInstalled();
setFfmpegInstalled(installed);
}
// Check if FFmpeg is installed for GIF conversion
const installed = await IsFFmpegInstalled();
setFfmpegInstalled(installed);
} else {
logger.error(response.message);
toast.error("Download failed");
@@ -635,7 +666,16 @@ export function MediaList({
if (response.success) {
logger.success(`Converted ${response.converted} GIFs`);
toast.success(`${response.converted} GIFs converted`);
setHasGifs(false);
// Re-check if gifs folder still has MP4 files after conversion
const settings = getSettings();
let folderName = accountInfo.name;
if (accountInfo.nick === "My Bookmarks" || accountInfo.name === "bookmarks") {
folderName = "My Bookmarks";
} else if (accountInfo.nick === "My Likes" || accountInfo.name === "likes") {
folderName = "My Likes";
}
const hasMP4 = await CheckGifsFolderHasMP4(settings.downloadPath, folderName);
setGifsFolderHasMP4(hasMP4);
} else {
logger.error(response.message);
toast.error("Convert failed");
@@ -745,24 +785,30 @@ export function MediaList({
</SelectTrigger>
<SelectContent>
<SelectItem value="all">All ({formatNumberWithComma(totalUrls)})</SelectItem>
<SelectItem value="photo">
<span className="flex items-center gap-2">
<Image className="h-4 w-4 text-blue-500" />
Images ({formatNumberWithComma(mediaCounts.photo)})
</span>
</SelectItem>
<SelectItem value="video">
<span className="flex items-center gap-2">
<Video className="h-4 w-4 text-purple-500" />
Videos ({formatNumberWithComma(mediaCounts.video)})
</span>
</SelectItem>
<SelectItem value="gif">
<span className="flex items-center gap-2">
<Film className="h-4 w-4 text-green-500" />
GIFs ({formatNumberWithComma(mediaCounts.gif)})
</span>
</SelectItem>
{mediaCounts.photo > 0 && (
<SelectItem value="photo">
<span className="flex items-center gap-2">
<Image className="h-4 w-4 text-blue-500" />
Images ({formatNumberWithComma(mediaCounts.photo)})
</span>
</SelectItem>
)}
{mediaCounts.video > 0 && (
<SelectItem value="video">
<span className="flex items-center gap-2">
<Video className="h-4 w-4 text-purple-500" />
Videos ({formatNumberWithComma(mediaCounts.video)})
</span>
</SelectItem>
)}
{mediaCounts.gif > 0 && (
<SelectItem value="gif">
<span className="flex items-center gap-2">
<Film className="h-4 w-4 text-green-500" />
GIFs ({formatNumberWithComma(mediaCounts.gif)})
</span>
</SelectItem>
)}
</SelectContent>
</Select>
)}
@@ -796,27 +842,23 @@ export function MediaList({
</div>
<div className="flex-1" />
{hasDownloaded && (
<Button variant="outline" onClick={handleOpenFolder}>
<FolderOpen className="h-4 w-4" />
Open Folder
</Button>
)}
{hasGifs && ffmpegInstalled && (
<Button variant="outline" onClick={handleConvertGifs} disabled={isConverting}>
{isConverting ? (
<>
<Spinner />
Converting...
</>
) : (
<>
<Film className="h-4 w-4" />
Convert GIFs
</>
)}
</Button>
)}
<Button variant="outline" onClick={handleOpenFolder} disabled={!folderExists}>
<FolderOpen className="h-4 w-4" />
Open Folder
</Button>
<Button variant="outline" onClick={handleConvertGifs} disabled={isConverting || !gifsFolderHasMP4 || !ffmpegInstalled}>
{isConverting ? (
<>
<Spinner />
Converting...
</>
) : (
<>
<Film className="h-4 w-4" />
Convert GIFs
</>
)}
</Button>
<div className="flex items-center gap-2">
{isDownloading && (
<Button variant="destructive" onClick={handleStopDownload}>
@@ -1234,7 +1276,7 @@ export function MediaList({
{/* Counter - above media */}
<div className="text-white text-sm bg-black/50 px-4 py-1.5 rounded-full mb-4">
{previewIndex + 1} / {filteredTimeline.length}
{formatNumberWithComma(previewIndex + 1)} / {formatNumberWithComma(filteredTimeline.length)}
</div>
{/* Media content - center */}
+17 -13
View File
@@ -28,6 +28,10 @@ import {
AlertCircle,
} from "lucide-react";
import { Spinner } from "@/components/ui/spinner";
function formatNumberWithComma(num: number): string {
return num.toLocaleString();
}
import { Checkbox } from "@/components/ui/checkbox";
import {
Select,
@@ -386,7 +390,7 @@ export function SearchBar({
{/* Timer Display */}
{(remainingTime !== null || elapsedTime > 0) && (
<div className="flex items-center gap-1.5 px-3 py-1.5 border rounded-md bg-muted/50 text-sm w-[85px]">
<Clock className="h-3.5 w-3.5 text-muted-foreground flex-shrink-0" />
<Clock className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
<span className="font-mono">
{remainingTime !== null && remainingTime >= 0
? `${Math.floor(remainingTime / 60)}:${String(remainingTime % 60).padStart(2, "0")}`
@@ -505,7 +509,7 @@ export function SearchBar({
{/* Timer Display */}
{(remainingTime !== null || elapsedTime > 0) && (
<div className="flex items-center gap-1.5 px-3 py-1.5 border rounded-md bg-muted/50 text-sm w-[85px]">
<Clock className="h-3.5 w-3.5 text-muted-foreground flex-shrink-0" />
<Clock className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
<span className="font-mono">
{remainingTime !== null && remainingTime >= 0
? `${Math.floor(remainingTime / 60)}:${String(remainingTime % 60).padStart(2, "0")}`
@@ -614,10 +618,10 @@ export function SearchBar({
</SelectTrigger>
<SelectContent>
<SelectItem value="all">All Media</SelectItem>
<SelectItem value="image">Images Only</SelectItem>
<SelectItem value="video">Videos Only</SelectItem>
<SelectItem value="gif">GIFs Only</SelectItem>
<SelectItem value="text">Text Only (No Media)</SelectItem>
<SelectItem value="image">Images</SelectItem>
<SelectItem value="video">Videos</SelectItem>
<SelectItem value="gif">GIFs</SelectItem>
<SelectItem value="text">Text (No Media)</SelectItem>
</SelectContent>
</Select>
</div>
@@ -688,29 +692,29 @@ export function SearchBar({
<CheckCircle className="h-4 w-4 text-green-600 dark:text-green-400" />
<span className="text-muted-foreground">Completed:</span>
<span className="font-medium">
{multipleAccounts.filter((acc) => acc.status === "completed").length}
{formatNumberWithComma(multipleAccounts.filter((acc) => acc.status === "completed").length)}
</span>
</div>
<div className="flex items-center gap-2">
<AlertCircle className="h-4 w-4 text-yellow-600 dark:text-yellow-400" />
<span className="text-muted-foreground">Incomplete:</span>
<span className="font-medium">
{multipleAccounts.filter((acc) => acc.status === "incomplete").length}
{formatNumberWithComma(multipleAccounts.filter((acc) => acc.status === "incomplete").length)}
</span>
</div>
<div className="flex items-center gap-2">
<XCircle className="h-4 w-4 text-red-600 dark:text-red-400" />
<span className="text-muted-foreground">Failed:</span>
<span className="font-medium">
{multipleAccounts.filter((acc) => acc.status === "failed").length}
{formatNumberWithComma(multipleAccounts.filter((acc) => acc.status === "failed").length)}
</span>
</div>
<div className="flex items-center gap-2 ml-auto">
<span className="text-muted-foreground">Total:</span>
<span className="font-medium">
{multipleAccounts.filter((acc) =>
{formatNumberWithComma(multipleAccounts.filter((acc) =>
acc.status === "completed" || acc.status === "incomplete" || acc.status === "failed"
).length}/{multipleAccounts.length}
).length)}/{formatNumberWithComma(multipleAccounts.length)}
</span>
</div>
</div>
@@ -720,7 +724,7 @@ export function SearchBar({
{/* Account List - below auth token and advanced settings */}
{fetchType === "multiple" && multipleAccounts.length > 0 && (
<div className="space-y-2">
<p className="text-sm text-muted-foreground">Accounts to Fetch ({multipleAccounts.length})</p>
<p className="text-sm text-muted-foreground">Accounts to Fetch ({formatNumberWithComma(multipleAccounts.length)})</p>
<div className="space-y-2 max-h-[400px] overflow-y-auto">
{multipleAccounts.map((account) => (
<div
@@ -767,7 +771,7 @@ export function SearchBar({
{account.status === "fetching" && (
<>
<div className="flex items-center gap-1.5 px-3 py-1.5 border rounded-md bg-muted/50 text-sm w-[85px]">
<Clock className="h-3.5 w-3.5 text-muted-foreground flex-shrink-0" />
<Clock className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
<span className="font-mono">
{account.remainingTime !== null && account.remainingTime >= 0
? formatTime(account.remainingTime)
+22 -32
View File
@@ -10,7 +10,7 @@ import {
SelectValue,
} from "@/components/ui/select";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { FolderOpen, Save, RotateCcw, Info, Download, Check, Volume2 } from "lucide-react";
import { FolderOpen, Save, RotateCcw, Info, Download, Check } from "lucide-react";
import { Spinner } from "@/components/ui/spinner";
import { Switch } from "@/components/ui/switch";
import { getSettings, getSettingsWithDefaults, saveSettings, resetToDefaultSettings, applyThemeMode, applyFont, FONT_OPTIONS, type Settings as SettingsType, type FontFamily, type GifQuality, type GifResolution } from "@/lib/settings";
@@ -215,7 +215,6 @@ export function SettingsPage() {
{/* Sound Effects */}
<div className="flex items-center gap-3 pt-2">
<Volume2 className="h-4 w-4 text-muted-foreground" />
<Label htmlFor="sfx-enabled" className="cursor-pointer text-sm">Sound Effects</Label>
<Switch
id="sfx-enabled"
@@ -315,51 +314,42 @@ export function SettingsPage() {
{/* GIF Quality - only show if FFmpeg installed */}
{ffmpegInstalled && (
<>
<div className="space-y-2">
<Label htmlFor="gif-quality">GIF Quality</Label>
<div className="space-y-2">
<Label htmlFor="gif-quality">GIF Quality</Label>
<div className="flex items-center gap-2">
<Select
value={tempSettings.gifQuality}
onValueChange={(value: GifQuality) => {
setTempSettings((prev) => ({
...prev,
gifQuality: value,
// Auto-select "original" when switching to "better"
gifResolution: value === "better" ? "original" : prev.gifResolution,
}));
}}
>
<SelectTrigger id="gif-quality">
<SelectTrigger id="gif-quality" className="w-auto">
<SelectValue placeholder="Select quality" />
</SelectTrigger>
<SelectContent>
<SelectItem value="fast">Fast (Simple conversion)</SelectItem>
<SelectItem value="better">Better (Optimized palette)</SelectItem>
<SelectItem value="fast">Fast</SelectItem>
<SelectItem value="better">Better</SelectItem>
</SelectContent>
</Select>
<Select
value={tempSettings.gifResolution}
onValueChange={(value: GifResolution) => setTempSettings((prev) => ({ ...prev, gifResolution: value }))}
>
<SelectTrigger id="gif-resolution" className="w-auto">
<SelectValue placeholder="Resolution" />
</SelectTrigger>
<SelectContent>
<SelectItem value="original">Original</SelectItem>
<SelectItem value="high">High (800px)</SelectItem>
<SelectItem value="medium">Medium (600px)</SelectItem>
<SelectItem value="low">Low (400px)</SelectItem>
</SelectContent>
</Select>
</div>
{/* GIF Resolution - only show if Better quality selected */}
{tempSettings.gifQuality === "better" && (
<div className="space-y-2">
<Label htmlFor="gif-resolution">GIF Resolution</Label>
<Select
value={tempSettings.gifResolution}
onValueChange={(value: GifResolution) => setTempSettings((prev) => ({ ...prev, gifResolution: value }))}
>
<SelectTrigger id="gif-resolution">
<SelectValue placeholder="Select resolution" />
</SelectTrigger>
<SelectContent>
<SelectItem value="original">Original (No scaling, 15 fps)</SelectItem>
<SelectItem value="high">High (800px, 15 fps)</SelectItem>
<SelectItem value="medium">Medium (600px, 10 fps)</SelectItem>
<SelectItem value="low">Low (400px, 8 fps)</SelectItem>
</SelectContent>
</Select>
</div>
)}
</>
</div>
)}
{/* Proxy */}
+33 -22
View File
@@ -1,4 +1,4 @@
import { Home, Settings, Bug, Database, LayoutGrid } from "lucide-react";
import { Home, Settings, Bug, Database, LayoutGrid, Coffee, Github } from "lucide-react";
import {
Tooltip,
TooltipContent,
@@ -44,27 +44,23 @@ export function Sidebar({ currentPage, onPageChange }: SidebarProps) {
))}
</div>
{/* GitHub - below debug */}
<Tooltip delayDuration={0}>
<TooltipTrigger asChild>
<Button
variant="ghost"
size="icon"
className="h-10 w-10"
onClick={() => openExternal("https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/issues")}
>
<svg viewBox="0 0 24 24" className="h-5 w-5" fill="currentColor">
<path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" />
</svg>
</Button>
</TooltipTrigger>
<TooltipContent side="right">
<p>Report Bug</p>
</TooltipContent>
</Tooltip>
{/* Other Projects at bottom */}
<div className="mt-auto">
{/* Bottom icons */}
<div className="mt-auto flex flex-col gap-2">
<Tooltip delayDuration={0}>
<TooltipTrigger asChild>
<Button
variant="ghost"
size="icon"
className="h-10 w-10"
onClick={() => openExternal("https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/issues")}
>
<Github className="h-5 w-5" />
</Button>
</TooltipTrigger>
<TooltipContent side="right">
<p>Report Bug</p>
</TooltipContent>
</Tooltip>
<Tooltip delayDuration={0}>
<TooltipTrigger asChild>
<Button
@@ -80,6 +76,21 @@ export function Sidebar({ currentPage, onPageChange }: SidebarProps) {
<p>Other Projects</p>
</TooltipContent>
</Tooltip>
<Tooltip delayDuration={0}>
<TooltipTrigger asChild>
<Button
variant="ghost"
size="icon"
className="h-10 w-10"
onClick={() => openExternal("https://ko-fi.com/afkarxyz")}
>
<Coffee className="h-5 w-5" />
</Button>
</TooltipTrigger>
<TooltipContent side="right">
<p>Support me on Ko-fi</p>
</TooltipContent>
</Tooltip>
</div>
</div>
);
-66
View File
@@ -1,66 +0,0 @@
"use client"
import * as React from "react"
import * as AccordionPrimitive from "@radix-ui/react-accordion"
import { ChevronDownIcon } from "lucide-react"
import { cn } from "@/lib/utils"
function Accordion({
...props
}: React.ComponentProps<typeof AccordionPrimitive.Root>) {
return <AccordionPrimitive.Root data-slot="accordion" {...props} />
}
function AccordionItem({
className,
...props
}: React.ComponentProps<typeof AccordionPrimitive.Item>) {
return (
<AccordionPrimitive.Item
data-slot="accordion-item"
className={cn("border-b last:border-b-0", className)}
{...props}
/>
)
}
function AccordionTrigger({
className,
children,
...props
}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
return (
<AccordionPrimitive.Header className="flex">
<AccordionPrimitive.Trigger
data-slot="accordion-trigger"
className={cn(
"focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
className
)}
{...props}
>
{children}
<ChevronDownIcon className="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200" />
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
)
}
function AccordionContent({
className,
children,
...props
}: React.ComponentProps<typeof AccordionPrimitive.Content>) {
return (
<AccordionPrimitive.Content
data-slot="accordion-content"
className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
{...props}
>
<div className={cn("pt-0 pb-4", className)}>{children}</div>
</AccordionPrimitive.Content>
)
}
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
-92
View File
@@ -1,92 +0,0 @@
import * as React from "react"
import { cn } from "@/lib/utils"
function Card({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card"
className={cn(
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
className
)}
{...props}
/>
)
}
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-header"
className={cn(
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
className
)}
{...props}
/>
)
}
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-title"
className={cn("leading-none font-semibold", className)}
{...props}
/>
)
}
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-description"
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
)
}
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-action"
className={cn(
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
className
)}
{...props}
/>
)
}
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-content"
className={cn("px-6", className)}
{...props}
/>
)
}
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-footer"
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
{...props}
/>
)
}
export {
Card,
CardHeader,
CardFooter,
CardTitle,
CardAction,
CardDescription,
CardContent,
}
-127
View File
@@ -1,127 +0,0 @@
import * as React from "react"
import {
ChevronLeftIcon,
ChevronRightIcon,
MoreHorizontalIcon,
} from "lucide-react"
import { cn } from "@/lib/utils"
import { Button, buttonVariants } from "@/components/ui/button"
function Pagination({ className, ...props }: React.ComponentProps<"nav">) {
return (
<nav
role="navigation"
aria-label="pagination"
data-slot="pagination"
className={cn("mx-auto flex w-full justify-center", className)}
{...props}
/>
)
}
function PaginationContent({
className,
...props
}: React.ComponentProps<"ul">) {
return (
<ul
data-slot="pagination-content"
className={cn("flex flex-row items-center gap-1", className)}
{...props}
/>
)
}
function PaginationItem({ ...props }: React.ComponentProps<"li">) {
return <li data-slot="pagination-item" {...props} />
}
type PaginationLinkProps = {
isActive?: boolean
} & Pick<React.ComponentProps<typeof Button>, "size"> &
React.ComponentProps<"a">
function PaginationLink({
className,
isActive,
size = "icon",
...props
}: PaginationLinkProps) {
return (
<a
aria-current={isActive ? "page" : undefined}
data-slot="pagination-link"
data-active={isActive}
className={cn(
buttonVariants({
variant: isActive ? "outline" : "ghost",
size,
}),
className
)}
{...props}
/>
)
}
function PaginationPrevious({
className,
...props
}: React.ComponentProps<typeof PaginationLink>) {
return (
<PaginationLink
aria-label="Go to previous page"
size="default"
className={cn("gap-1 px-2.5 sm:pl-2.5", className)}
{...props}
>
<ChevronLeftIcon />
<span className="hidden sm:block">Previous</span>
</PaginationLink>
)
}
function PaginationNext({
className,
...props
}: React.ComponentProps<typeof PaginationLink>) {
return (
<PaginationLink
aria-label="Go to next page"
size="default"
className={cn("gap-1 px-2.5 sm:pr-2.5", className)}
{...props}
>
<span className="hidden sm:block">Next</span>
<ChevronRightIcon />
</PaginationLink>
)
}
function PaginationEllipsis({
className,
...props
}: React.ComponentProps<"span">) {
return (
<span
aria-hidden
data-slot="pagination-ellipsis"
className={cn("flex size-9 items-center justify-center", className)}
{...props}
>
<MoreHorizontalIcon className="size-4" />
<span className="sr-only">More pages</span>
</span>
)
}
export {
Pagination,
PaginationContent,
PaginationLink,
PaginationItem,
PaginationPrevious,
PaginationNext,
PaginationEllipsis,
}
@@ -1,45 +0,0 @@
"use client"
import * as React from "react"
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
import { CircleIcon } from "lucide-react"
import { cn } from "@/lib/utils"
function RadioGroup({
className,
...props
}: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
return (
<RadioGroupPrimitive.Root
data-slot="radio-group"
className={cn("grid gap-3", className)}
{...props}
/>
)
}
function RadioGroupItem({
className,
...props
}: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
return (
<RadioGroupPrimitive.Item
data-slot="radio-group-item"
className={cn(
"border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
className
)}
{...props}
>
<RadioGroupPrimitive.Indicator
data-slot="radio-group-indicator"
className="relative flex items-center justify-center"
>
<CircleIcon className="fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" />
</RadioGroupPrimitive.Indicator>
</RadioGroupPrimitive.Item>
)
}
export { RadioGroup, RadioGroupItem }