Compare commits

...
4 Commits
Author SHA1 Message Date
afkarxyz 2ada5da9bf v4.9 2026-07-16 18:27:23 +07:00
afkarxyz 3fb8bda2ff Update README 2026-07-15 12:26:49 +07:00
asdfghjkkly b4dfb75f5b Fix group editing and skip existing downloads (#105) 2026-07-12 10:59:29 +07:00
afkarxyz 7e584aff2c Update README 2026-07-12 10:58:42 +07:00
13 changed files with 221 additions and 106 deletions

No files matched your search

+25 -10
View File
@@ -1,20 +1,35 @@
# Twitter/X Media Batch Downloader <div align="left">
<h1>Twitter/X Media Batch Downloader</h1>
A GUI tool to download original-quality images and videos from Twitter/X accounts. <p>
Downloads original-quality images and videos from Twitter/X accounts.
![Windows](https://img.shields.io/badge/Windows-10%2B-0078D6?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MTIiIGhlaWdodD0iNTEyIiB2aWV3Qm94PSIwIDAgMjAgMjAiPjxwYXRoIGZpbGw9IiNmZmZmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTIwIDEwLjg3M1YyMEw4LjQ3OSAxOC41MzdsLjAwMS03LjY2NEgyMFptLTEzLjEyIDBsLS4wMDEgNy40NjFMMCAxNy40NjF2LTYuNTg4aDYuODhaTTIwIDkuMjczSDguNDhsLS4wMDEtNy44MUwyMCAwdjkuMjczWk02Ljg3OSAxLjY2NmwuMDAxIDcuNjA3SDBWMi41MzlsNi44NzktLjg3M1oiLz48L3N2Zz4=) </p>
![macOS](https://img.shields.io/badge/macOS-10.13%2B-000000?style=for-the-badge&logo=apple&logoColor=white) <p>
![Linux](https://img.shields.io/badge/Linux-Any-FCC624?style=for-the-badge&logo=linux&logoColor=white) <a href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/stargazers"><img
src="https://img.shields.io/github/stars/afkarxyz/Twitter-X-Media-Batch-Downloader?color=ffcb47&labelColor=black&logo=github&label=Stars" /></a><a
href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases"><img
src="https://img.shields.io/github/downloads/afkarxyz/Twitter-X-Media-Batch-Downloader/total?color=22c55e&labelColor=black&logo=github&label=Downloads" /></a><a
href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/latest"><img
src="https://img.shields.io/github/v/release/afkarxyz/Twitter-X-Media-Batch-Downloader?color=8b5cf6&labelColor=black&logo=github&label=Latest%20Release" /></a><a
href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/latest"><img
src="https://img.shields.io/badge/Windows-10%2B-369eff?labelColor=black&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1MTIiIGhlaWdodD0iNTEyIiB2aWV3Qm94PSIwIDAgMjAgMjAiPjxwYXRoIGZpbGw9IiNmZmZmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTIwIDEwLjg3M1YyMEw4LjQ3OSAxOC41MzdsLjAwMS03LjY2NEgyMFptLTEzLjEyIDBsLS4wMDEgNy40NjFMMCAxNy40NjF2LTYuNTg4aDYuODhaTTIwIDkuMjczSDguNDhsLS4wMDEtNy44MUwyMCAwdjkuMjczWk02Ljg3OSAxLjY2NmwuMDAxIDcuNjA3SDBWMi41MzlsNi44NzktLjg3M1oiLz48L3N2Zz4=" /></a><a
href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/latest"><img
src="https://img.shields.io/badge/macOS-10.13%2B-FFFFFF?labelColor=black&logo=apple&logoColor=white" /></a><a
href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/latest"><img
src="https://img.shields.io/badge/Linux-Any-FCC624?labelColor=black&logo=linux&logoColor=white" /></a>
<br />
<br />
<a href="https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases/latest" target="_blank"><img
src="https://github.com/user-attachments/assets/cef7b7e6-5a64-497a-91fe-b6fb549f3b09" alt="Twitter/X Media Batch Downloader" /></a>
</p>
</div>
### [Download](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases) ### [Download](https://github.com/afkarxyz/Twitter-X-Media-Batch-Downloader/releases)
![Image](https://github.com/user-attachments/assets/cef7b7e6-5a64-497a-91fe-b6fb549f3b09)
- If you're familiar with userscripts, install it [**here**](https://greasyfork.org/en/scripts/523157) - If you're familiar with userscripts, install it [**here**](https://greasyfork.org/en/scripts/523157)
- To install the Chrome extension version, click [**here**](https://chromewebstore.google.com/detail/cboceolmgkoobpfjiojkigmihijfgmdo) - To install the Chrome extension version, click [**here**](https://chromewebstore.google.com/detail/cboceolmgkoobpfjiojkigmihijfgmdo)
- Also available on the web at [**MediaBatchDL.com**](https://mediabatchdl.com) - Also available on the web at [**TwitterDL.app**](https://twitterdl.app)
## How to Obtain Auth Token ## How to Obtain Auth Token
+20 -1
View File
@@ -341,10 +341,29 @@ func DownloadMediaWithMetadataProgressAndStatus(items []MediaItem, outputDir str
filenameIndexes := make(map[string]int, len(filenameCounts)) filenameIndexes := make(map[string]int, len(filenameCounts))
tasks := make([]downloadTask, 0, len(pendingTasks)) tasks := make([]downloadTask, 0, len(pendingTasks))
for _, pending := range pendingTasks { for _, pending := range pendingTasks {
key := filenameCollisionKey(pending.typeDir, pending.baseName, pending.ext) key := filenameCollisionKey(pending.typeDir, pending.baseName, pending.ext)
filenameIndexes[key]++ filenameIndexes[key]++
pending.task.outputPath = filepath.Join(pending.typeDir, formatDownloadFilename(pending.baseName, pending.ext, filenameCounts[key], filenameIndexes[key]))
filename := formatDownloadFilename(
pending.baseName,
pending.ext,
filenameCounts[key],
filenameIndexes[key],
)
if options.SkipExistingFiles {
canonicalPath := filepath.Join(pending.typeDir, formatDownloadFilename(pending.baseName, pending.ext, 1, 1))
if exists, err := fileExists(canonicalPath); err == nil && exists {
pending.task.outputPath = canonicalPath
tasks = append(tasks, pending.task)
continue
}
}
pending.task.outputPath = filepath.Join(pending.typeDir, filename)
tasks = append(tasks, pending.task) tasks = append(tasks, pending.task)
} }
+1 -1
View File
@@ -11,7 +11,7 @@ import (
) )
func OpenFolderInExplorer(path string) error { func OpenFolderInExplorer(path string) error {
os.WriteFile(filepath.Join(os.TempDir(), "openfolder.txt"), []byte(path), 0644) os.WriteFile(filepath.Join(os.TempDir(), "openfolder.txt"), []byte(path), 0644)
info, err := os.Stat(path) info, err := os.Stat(path)
if err != nil { if err != nil {
return err return err
+2 -3
View File
@@ -698,11 +698,10 @@ func ExtractTimeline(req TimelineRequest) (*TwitterResponse, error) {
} }
includeText := req.IncludeText includeText := req.IncludeText
wantsRetweets := req.Retweets
timelineType := req.TimelineType timelineType := req.TimelineType
if timelineType == "" { if timelineType == "" {
if includeText || wantsRetweets { if includeText {
timelineType = "tweets" timelineType = "tweets"
} else { } else {
timelineType = "media" timelineType = "media"
@@ -725,7 +724,7 @@ func ExtractTimeline(req TimelineRequest) (*TwitterResponse, error) {
args = append(args, "--limit", fmt.Sprintf("%d", req.BatchSize)) args = append(args, "--limit", fmt.Sprintf("%d", req.BatchSize))
} }
if timelineType == "tweets" || timelineType == "timeline" { if timelineType == "tweets" || timelineType == "timeline" || timelineType == "media" {
if req.Retweets { if req.Retweets {
args = append(args, "--retweets", "include") args = append(args, "--retweets", "include")
} else { } else {
+1 -1
View File
@@ -441,7 +441,7 @@ function App() {
} }
else { else {
const batchSize = BATCH_SIZE; const batchSize = BATCH_SIZE;
let timelineType = (settings.includeText || retweets) ? "tweets" : "media"; let timelineType = settings.includeText ? "tweets" : "media";
if (isBookmarks) { if (isBookmarks) {
timelineType = "bookmarks"; timelineType = "bookmarks";
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

+68 -47
View File
@@ -13,11 +13,16 @@ import { Spinner } from "@/components/ui/spinner";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
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, Users, MessageSquare } 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, Users, MessageSquare } from "lucide-react";
import { toastWithSound as toast } from "@/lib/toast-with-sound"; import { toastWithSound as toast } from "@/lib/toast-with-sound";
import { getSettings, renderFolderTemplate } from "@/lib/settings"; import { getSettings } from "@/lib/settings";
import { beginDownload, finishDownload, useDownloadState } from "@/lib/download-state";
import { openExternal } from "@/lib/utils"; import { openExternal } from "@/lib/utils";
import { GetAllAccountsFromDB, GetAccountFromDB, DeleteAccountFromDB, SaveAccountToDB, ExportAccountJSON, ExportAccountsTXT, UpdateAccountGroup, GetAllGroups, DownloadMediaWithMetadata, StopDownload, CheckFoldersExist, OpenFolder, GetFolderPath, } from "../../wailsjs/go/main/App"; import { GetAllAccountsFromDB, GetAccountFromDB, DeleteAccountFromDB, SaveAccountToDB, ExportAccountJSON, ExportAccountsTXT, UpdateAccountGroup, GetAllGroups, DownloadMediaWithMetadata, StopDownload, CheckFoldersExist, OpenFolder, GetFolderPath, } from "../../wailsjs/go/main/App";
import { EventsOn } from "../../wailsjs/runtime/runtime";
import { main } from "../../wailsjs/go/models"; import { main } from "../../wailsjs/go/models";
interface DownloadProgress {
current: number;
total: number;
percent: number;
}
function formatNumberWithComma(num: number): string { function formatNumberWithComma(num: number): string {
return num.toLocaleString(); return num.toLocaleString();
} }
@@ -88,31 +93,23 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
const [editGroupName, setEditGroupName] = useState(""); const [editGroupName, setEditGroupName] = useState("");
const [editGroupColor, setEditGroupColor] = useState(""); const [editGroupColor, setEditGroupColor] = useState("");
const [clearAllDialogOpen, setClearAllDialogOpen] = useState(false); const [clearAllDialogOpen, setClearAllDialogOpen] = useState(false);
const [isDownloading, setIsDownloading] = useState(false);
const [downloadingAccountId, setDownloadingAccountId] = useState<number | null>(null);
const [downloadProgress, setDownloadProgress] = useState<DownloadProgress | null>(null);
const [isBulkDownloading, setIsBulkDownloading] = useState(false); const [isBulkDownloading, setIsBulkDownloading] = useState(false);
const [bulkDownloadCurrent, setBulkDownloadCurrent] = useState(0); const [bulkDownloadCurrent, setBulkDownloadCurrent] = useState(0);
const [bulkDownloadTotal, setBulkDownloadTotal] = useState(0); const [bulkDownloadTotal, setBulkDownloadTotal] = useState(0);
const stopBulkDownloadRef = useRef(false); const stopBulkDownloadRef = useRef(false);
const loadMoreRef = useRef<HTMLDivElement>(null); const loadMoreRef = useRef<HTMLDivElement>(null);
const [folderExistence, setFolderExistence] = useState<Map<number, boolean>>(new Map()); const [folderExistence, setFolderExistence] = useState<Map<number, boolean>>(new Map());
const downloadState = useDownloadState(); const getFolderNameForAccount = (username: string) => {
const anyDownloadActive = downloadState.active;
const isDownloading = downloadState.active && (downloadState.scope === "database" || downloadState.scope === "database-bulk");
const downloadingAccountId = isDownloading ? downloadState.accountId : null;
const downloadProgress = isDownloading ? downloadState.progress : null;
const getFolderNameForAccount = (username: string, accountName?: string) => {
if (username === "bookmarks") { if (username === "bookmarks") {
return "My Bookmarks"; return "My Bookmarks";
} }
if (username === "likes") { if (username === "likes") {
return "My Likes"; return "My Likes";
} }
const now = new Date(); return username;
const date = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, "0")}${String(now.getDate()).padStart(2, "0")}`;
return renderFolderTemplate(getSettings().folderTemplate, {
username,
accountName: accountName || username,
date,
}) || username;
}; };
const loadAccounts = useCallback(async () => { const loadAccounts = useCallback(async () => {
setLoading(true); setLoading(true);
@@ -150,6 +147,14 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
scrollElement.addEventListener("scroll", handleScroll); scrollElement.addEventListener("scroll", handleScroll);
return () => scrollElement.removeEventListener("scroll", handleScroll); return () => scrollElement.removeEventListener("scroll", handleScroll);
}, []); }, []);
useEffect(() => {
const unsubscribe = EventsOn("download-progress", (progress: DownloadProgress) => {
setDownloadProgress(progress);
});
return () => {
unsubscribe();
};
}, []);
const scrollToTop = () => { const scrollToTop = () => {
getContentScrollElement()?.scrollTo({ top: 0, behavior: "smooth" }); getContentScrollElement()?.scrollTo({ top: 0, behavior: "smooth" });
}; };
@@ -221,7 +226,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
}, [accountViewMode, filterGroup, filterMediaType, privateAccounts, publicAccounts, deferredSearchQuery, sortOrder]); }, [accountViewMode, filterGroup, filterMediaType, privateAccounts, publicAccounts, deferredSearchQuery, sortOrder]);
const visibleAccounts = useMemo(() => filteredAccounts.slice(0, visibleCount), [filteredAccounts, visibleCount]); const visibleAccounts = useMemo(() => filteredAccounts.slice(0, visibleCount), [filteredAccounts, visibleCount]);
const visibleAccountsKey = visibleAccounts const visibleAccountsKey = visibleAccounts
.map((account) => `${account.id}:${account.username}:${account.name}`) .map((account) => `${account.id}:${account.username}`)
.join("|"); .join("|");
useEffect(() => { useEffect(() => {
const basePath = currentDownloadPath; const basePath = currentDownloadPath;
@@ -235,7 +240,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
let active = true; let active = true;
const loadVisibleFolderExistence = async () => { const loadVisibleFolderExistence = async () => {
try { try {
const folderNames = visibleAccounts.map((account) => getFolderNameForAccount(account.username, account.name)); const folderNames = visibleAccounts.map((account) => getFolderNameForAccount(account.username));
const results = await CheckFoldersExist(basePath, folderNames); const results = await CheckFoldersExist(basePath, folderNames);
if (!active) { if (!active) {
return; return;
@@ -243,7 +248,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
setFolderExistence((prev) => { setFolderExistence((prev) => {
const next = new Map(prev); const next = new Map(prev);
for (const account of visibleAccounts) { for (const account of visibleAccounts) {
next.set(account.id, results[getFolderNameForAccount(account.username, account.name)] ?? false); next.set(account.id, results[getFolderNameForAccount(account.username)] ?? false);
} }
return next; return next;
}); });
@@ -313,13 +318,26 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
}; };
const handleOpenFolder = async (account: AccountListItem) => { const handleOpenFolder = async (account: AccountListItem) => {
const settings = getSettings(); const settings = getSettings();
const folderName = getFolderNameForAccount(account.username, account.name); const basePath = settings.downloadPath || "";
const folderPath = await GetFolderPath(settings.downloadPath, folderName); if (!basePath) {
toast.error("Download folder is not set");
return;
}
let username = account.username || account.name || "";
try { try {
const responseJSON = await GetAccountFromDB(account.id);
const data = JSON.parse(responseJSON);
username = data.account_info?.name || username;
}
catch {
}
const folderName = getFolderNameForAccount(username);
try {
const folderPath = await GetFolderPath(basePath, folderName);
await OpenFolder(folderPath); await OpenFolder(folderPath);
} }
catch (error) { catch (error) {
console.error(`Failed to open folder for @${account.username}:`, error); console.error(`Failed to open folder for @${username}:`, error);
toast.error("Failed to open folder"); toast.error("Failed to open folder");
} }
}; };
@@ -345,7 +363,9 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
outputDir = `${settings.downloadPath}${separator}My Likes`; outputDir = `${settings.downloadPath}${separator}My Likes`;
} }
const actualUsername = data.account_info?.name || username; const actualUsername = data.account_info?.name || username;
beginDownload({ current: 0, total: timeline.length, percent: 0 }, { scope: "database", accountId: id }); setIsDownloading(true);
setDownloadingAccountId(id);
setDownloadProgress({ current: 0, total: timeline.length, percent: 0 });
const request = new main.DownloadMediaWithMetadataRequest({ const request = new main.DownloadMediaWithMetadataRequest({
items: timeline.map((item: { items: timeline.map((item: {
url: string; url: string;
@@ -354,7 +374,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
type: string; type: string;
original_filename?: string; original_filename?: string;
author_username?: string; author_username?: string;
author_name?: string;
}) => new main.MediaItemRequest({ }) => new main.MediaItemRequest({
url: item.url, url: item.url,
date: item.date, date: item.date,
@@ -362,7 +381,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
type: item.type, type: item.type,
original_filename: item.original_filename || "", original_filename: item.original_filename || "",
author_username: item.author_username || "", author_username: item.author_username || "",
account_name: item.author_name || data.account_info?.nick || actualUsername,
})), })),
output_dir: outputDir, output_dir: outputDir,
username: actualUsername, username: actualUsername,
@@ -373,9 +391,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
proxy: settings.proxy || "", proxy: settings.proxy || "",
filename_template: settings.filenameTemplate || "", filename_template: settings.filenameTemplate || "",
folder_template: settings.folderTemplate || "", folder_template: settings.folderTemplate || "",
auto_convert_gifs: settings.autoConvertGifs,
gif_quality: settings.gifQuality || "fast",
gif_resolution: settings.gifResolution || "original",
}); });
const response = await DownloadMediaWithMetadata(request); const response = await DownloadMediaWithMetadata(request);
if (response.cancelled) { if (response.cancelled) {
@@ -412,14 +427,15 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
toast.error(`Download failed: ${errorMsg}`); toast.error(`Download failed: ${errorMsg}`);
} }
finally { finally {
finishDownload(); setIsDownloading(false);
setDownloadingAccountId(null);
setDownloadProgress(null);
} }
}; };
const handleStopDownload = async () => { const handleStopDownload = async () => {
try { try {
const stopped = await StopDownload(); const stopped = await StopDownload();
if (stopped) { if (stopped) {
finishDownload();
toast.info("Download stopped"); toast.info("Download stopped");
} }
} }
@@ -451,7 +467,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
if (!account) if (!account)
continue; continue;
setBulkDownloadCurrent(i + 1); setBulkDownloadCurrent(i + 1);
beginDownload({ current: 0, total: 0, percent: 0 }, { scope: "database-bulk", accountId: id }); setDownloadingAccountId(id);
try { try {
const responseJSON = await GetAccountFromDB(id); const responseJSON = await GetAccountFromDB(id);
const data = JSON.parse(responseJSON); const data = JSON.parse(responseJSON);
@@ -462,7 +478,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
toast.info("Bulk download stopped"); toast.info("Bulk download stopped");
break; break;
} }
beginDownload({ current: 0, total: timeline.length, percent: 0 }, { scope: "database-bulk", accountId: id }); setDownloadProgress({ current: 0, total: timeline.length, percent: 0 });
const isBookmarks = data.account_info?.nick === "My Bookmarks" || account.username === "bookmarks"; const isBookmarks = data.account_info?.nick === "My Bookmarks" || account.username === "bookmarks";
const isLikes = data.account_info?.nick === "My Likes" || account.username === "likes"; const isLikes = data.account_info?.nick === "My Likes" || account.username === "likes";
let outputDir = settings.downloadPath; let outputDir = settings.downloadPath;
@@ -482,7 +498,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
tweet_id: string; tweet_id: string;
type: string; type: string;
author_username?: string; author_username?: string;
author_name?: string;
original_filename?: string; original_filename?: string;
}) => new main.MediaItemRequest({ }) => new main.MediaItemRequest({
url: item.url, url: item.url,
@@ -490,7 +505,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
tweet_id: item.tweet_id, tweet_id: item.tweet_id,
type: item.type, type: item.type,
author_username: item.author_username || "", author_username: item.author_username || "",
account_name: item.author_name || data.account_info?.nick || actualUsername,
original_filename: item.original_filename || "", original_filename: item.original_filename || "",
})), })),
output_dir: outputDir, output_dir: outputDir,
@@ -502,9 +516,6 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
proxy: settings.proxy || "", proxy: settings.proxy || "",
filename_template: settings.filenameTemplate || "", filename_template: settings.filenameTemplate || "",
folder_template: settings.folderTemplate || "", folder_template: settings.folderTemplate || "",
auto_convert_gifs: settings.autoConvertGifs,
gif_quality: settings.gifQuality || "fast",
gif_resolution: settings.gifResolution || "original",
}); });
const response = await DownloadMediaWithMetadata(request); const response = await DownloadMediaWithMetadata(request);
if (response.cancelled) { if (response.cancelled) {
@@ -523,7 +534,8 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
} }
} }
setIsBulkDownloading(false); setIsBulkDownloading(false);
finishDownload(); setDownloadingAccountId(null);
setDownloadProgress(null);
setBulkDownloadCurrent(0); setBulkDownloadCurrent(0);
setBulkDownloadTotal(0); setBulkDownloadTotal(0);
if ((totalDownloaded > 0 || totalSkipped > 0) && !stopBulkDownloadRef.current) { if ((totalDownloaded > 0 || totalSkipped > 0) && !stopBulkDownloadRef.current) {
@@ -820,7 +832,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
<TooltipContent>Stop Bulk Download</TooltipContent> <TooltipContent>Stop Bulk Download</TooltipContent>
</Tooltip>) : (<Tooltip> </Tooltip>) : (<Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<Button variant="default" size="icon" onClick={handleBulkDownload} disabled={selectedIds.size === 0 || anyDownloadActive}> <Button variant="default" size="icon" onClick={handleBulkDownload} disabled={selectedIds.size === 0 || isDownloading}>
<Download className="h-4 w-4"/> <Download className="h-4 w-4"/>
</Button> </Button>
</TooltipTrigger> </TooltipTrigger>
@@ -1048,10 +1060,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
{formatNumberWithComma(account.total_media)} media {formatNumberWithComma(account.total_media)} media
</div> </div>
</div> </div>
<div className="flex gap-1"> <div className="flex gap-1" onClick={(e) => e.stopPropagation()}>
{downloadingAccountId === account.id ? (<Button variant="outline" size="icon" className="h-8 w-8" onClick={handleStopDownload}> {downloadingAccountId === account.id ? (<Button variant="outline" size="icon" className="h-8 w-8" onClick={handleStopDownload}>
<StopCircle className="h-4 w-4 text-destructive"/> <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={anyDownloadActive}> </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"/> <Download className="h-4 w-4"/>
</Button>)} </Button>)}
<Button variant="outline" size="icon" className="h-8 w-8" onClick={() => handleOpenFolder(account)} disabled={!folderExistence.get(account.id)}> <Button variant="outline" size="icon" className="h-8 w-8" onClick={() => handleOpenFolder(account)} disabled={!folderExistence.get(account.id)}>
@@ -1064,7 +1076,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent align="end"> <DropdownMenuContent align="end">
{!isPrivateAccount(account.username) && (<DropdownMenuItem onClick={() => handleEditGroup(account)}> {!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
event.preventDefault();
handleEditGroup(account);
}}>
<Pencil className="h-4 w-4 mr-2"/> <Pencil className="h-4 w-4 mr-2"/>
Edit Group Edit Group
</DropdownMenuItem>)} </DropdownMenuItem>)}
@@ -1142,10 +1157,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
{formatNumberWithComma(account.total_media)} media {formatNumberWithComma(account.total_media)} media
</div> </div>
</div> </div>
<div className="flex gap-1"> <div className="flex gap-1" onClick={(e) => e.stopPropagation()}>
{downloadingAccountId === account.id ? (<Button variant="outline" size="icon" className="h-7 w-7" onClick={handleStopDownload}> {downloadingAccountId === account.id ? (<Button variant="outline" size="icon" className="h-7 w-7" onClick={handleStopDownload}>
<StopCircle className="h-3 w-3 text-destructive"/> <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={anyDownloadActive}> </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"/> <Download className="h-3 w-3"/>
</Button>)} </Button>)}
<Button variant="outline" size="icon" className="h-7 w-7" onClick={() => handleOpenFolder(account)} disabled={!folderExistence.get(account.id)}> <Button variant="outline" size="icon" className="h-7 w-7" onClick={() => handleOpenFolder(account)} disabled={!folderExistence.get(account.id)}>
@@ -1158,7 +1173,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent align="end"> <DropdownMenuContent align="end">
{!isPrivateAccount(account.username) && (<DropdownMenuItem onClick={() => handleEditGroup(account)}> {!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
event.preventDefault();
handleEditGroup(account);
}}>
<Pencil className="h-4 w-4 mr-2"/> <Pencil className="h-4 w-4 mr-2"/>
Edit Group Edit Group
</DropdownMenuItem>)} </DropdownMenuItem>)}
@@ -1253,7 +1271,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
{account.last_fetched} {getRelativeTime(account.last_fetched)} {account.last_fetched} {getRelativeTime(account.last_fetched)}
</div> </div>
</div> </div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2" onClick={(e) => e.stopPropagation()}>
{downloadingAccountId === account.id ? (<Tooltip> {downloadingAccountId === account.id ? (<Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<Button variant="outline" size="icon" onClick={handleStopDownload}> <Button variant="outline" size="icon" onClick={handleStopDownload}>
@@ -1263,7 +1281,7 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
<TooltipContent>Stop Download</TooltipContent> <TooltipContent>Stop Download</TooltipContent>
</Tooltip>) : (<Tooltip> </Tooltip>) : (<Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<Button variant="default" size="icon" onClick={() => handleDownload(account.id, account.username)} disabled={anyDownloadActive}> <Button variant="default" size="icon" onClick={() => handleDownload(account.id, account.username)} disabled={isDownloading}>
{isDownloading && downloadingAccountId === account.id ? (<Spinner className="h-4 w-4"/>) : (<Download className="h-4 w-4"/>)} {isDownloading && downloadingAccountId === account.id ? (<Spinner className="h-4 w-4"/>) : (<Download className="h-4 w-4"/>)}
</Button> </Button>
</TooltipTrigger> </TooltipTrigger>
@@ -1289,7 +1307,10 @@ export function DatabaseView({ onLoadAccount, onUpdateSelected }: DatabaseViewPr
<TooltipContent>More Options</TooltipContent> <TooltipContent>More Options</TooltipContent>
</Tooltip> </Tooltip>
<DropdownMenuContent align="end"> <DropdownMenuContent align="end">
{!isPrivateAccount(account.username) && (<DropdownMenuItem onClick={() => handleEditGroup(account)}> {!isPrivateAccount(account.username) && (<DropdownMenuItem onSelect={(event) => {
event.preventDefault();
handleEditGroup(account);
}}>
<Pencil className="h-4 w-4 mr-2"/> <Pencil className="h-4 w-4 mr-2"/>
Edit Group Edit Group
</DropdownMenuItem>)} </DropdownMenuItem>)}
+16 -1
View File
@@ -11,7 +11,7 @@ import { toastWithSound as toast } from "@/lib/toast-with-sound";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { getSettings, updateSettings, VIDEO_QUALITIES, IMAGE_SIZES, AVATAR_SIZES, BANNER_SIZES, type VideoQuality, type ImageSize, type AvatarSize, type BannerSize } from "@/lib/settings"; import { getSettings, updateSettings, VIDEO_QUALITIES, IMAGE_SIZES, AVATAR_SIZES, BANNER_SIZES, type VideoQuality, type ImageSize, type AvatarSize, type BannerSize } from "@/lib/settings";
import { GetStoredAuthToken, SetStoredAuthToken } from "../../wailsjs/go/main/App"; import { GetStoredAuthToken, SetStoredAuthToken } from "../../wailsjs/go/main/App";
import { AlertCircle, Bookmark, CheckCircle, CloudDownload, Clock, Database, Eye, EyeOff, Globe, Heart, Hourglass, Info, Lock, RotateCcw, SlidersHorizontal, StopCircle, Trash2, User, Users, XCircle } from "lucide-react"; import { AlertCircle, Bookmark, CheckCircle, Clipboard, CloudDownload, Clock, Database, Eye, EyeOff, Globe, Heart, Hourglass, Info, Lock, RotateCcw, SlidersHorizontal, StopCircle, Trash2, User, Users, XCircle } from "lucide-react";
import { Spinner } from "@/components/ui/spinner"; import { Spinner } from "@/components/ui/spinner";
function formatNumberWithComma(num: number): string { function formatNumberWithComma(num: number): string {
return num.toLocaleString(); return num.toLocaleString();
@@ -207,6 +207,17 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
onFetch(false, undefined, undefined, undefined, retweets, mode, privateType, authToken, false); onFetch(false, undefined, undefined, undefined, retweets, mode, privateType, authToken, false);
}); });
}; };
const handleClipboardPaste = async () => {
try {
const clipboardText = (await navigator.clipboard.readText()).trim();
if (clipboardText) {
onUsernameChange(clipboardText);
}
}
catch (error) {
console.error("Failed to read clipboard:", error);
}
};
const handleResume = () => { const handleResume = () => {
if (onResume) { if (onResume) {
requireAuthToken((authToken) => { requireAuthToken((authToken) => {
@@ -371,6 +382,10 @@ export function SearchBar({ username, loading, onUsernameChange, onFetch, onStop
</button>)} </button>)}
</div> </div>
<Button variant="outline" size="icon" className="shrink-0" aria-label="Paste from clipboard" onClick={() => void handleClipboardPaste()}>
<Clipboard className="h-4 w-4"/>
</Button>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
{loading && (<Button variant="destructive" onClick={onStopFetch}> {loading && (<Button variant="destructive" onClick={onStopFetch}>
<StopCircle className="h-4 w-4"/> <StopCircle className="h-4 w-4"/>
+85 -20
View File
@@ -1,16 +1,57 @@
import { useState } from "react"; import { useState } from "react";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { CircleCheck, Copy } from "lucide-react"; import { CircleCheck, Copy } from "lucide-react";
import { openExternal } from "@/lib/utils"; import { openExternal } from "@/lib/utils";
import KofiLogo from "@/assets/ko-fi.gif"; import KofiLogo from "@/assets/ko-fi.gif";
import KofiSvg from "@/assets/kofi_symbol.svg"; import KofiSvg from "@/assets/kofi_symbol.svg";
import UsdtBarcode from "@/assets/usdt.jpg"; import UsdtTronQr from "@/assets/usdt.jpg";
const USDT_ADDRESS = "THnzAAwZgp2Sq5CAXLP2njQDhTvgZG9EWs"; import UsdtEvmQr from "@/assets/usdt_evm.jpg";
import UsdcEvmQr from "@/assets/usdc.jpg";
type CryptoCoin = "usdt" | "usdc";
type CryptoNetwork = "ethereum" | "bsc" | "polygon" | "base" | "tron";
const EVM_ADDRESS = "0xB563a7F39770C151e2FacE26926081a00c5EF349";
const TRON_ADDRESS = "THnzAAwZgp2Sq5CAXLP2njQDhTvgZG9EWs";
const EVM_NETWORKS: Array<{
value: CryptoNetwork;
label: string;
shortLabel: string;
}> = [
{ value: "bsc", label: "BNB Smart Chain (BEP20)", shortLabel: "BEP20" },
{ value: "polygon", label: "Polygon", shortLabel: "Polygon" },
{ value: "ethereum", label: "Ethereum (ERC20)", shortLabel: "ERC20" },
{ value: "base", label: "Base", shortLabel: "Base" },
];
const USDT_NETWORKS: Array<{
value: CryptoNetwork;
label: string;
shortLabel: string;
}> = [
{ value: "ethereum", label: "Ethereum (ERC20)", shortLabel: "ERC20" },
{ value: "bsc", label: "BNB Smart Chain (BEP20)", shortLabel: "BEP20" },
{ value: "tron", label: "Tron (TRC20)", shortLabel: "TRC20" },
{ value: "polygon", label: "Polygon", shortLabel: "Polygon" },
];
export function SupportPage() { export function SupportPage() {
const [copiedUsdt, setCopiedUsdt] = useState(false); const [selectedCoin, setSelectedCoin] = useState<CryptoCoin>("usdt");
const [selectedNetwork, setSelectedNetwork] = useState<CryptoNetwork>("tron");
const [copiedAddress, setCopiedAddress] = useState(false);
const networkOptions = selectedCoin === "usdt" ? USDT_NETWORKS : EVM_NETWORKS;
const activeNetwork = networkOptions.find((network) => network.value === selectedNetwork) || EVM_NETWORKS[0];
const isTron = selectedNetwork === "tron";
const cryptoAddress = isTron ? TRON_ADDRESS : EVM_ADDRESS;
const cryptoQr = isTron ? UsdtTronQr : selectedCoin === "usdt" ? UsdtEvmQr : UsdcEvmQr;
const handleCoinChange = (coin: CryptoCoin) => {
setSelectedCoin(coin);
setCopiedAddress(false);
const nextNetworks = coin === "usdt" ? USDT_NETWORKS : EVM_NETWORKS;
if (!nextNetworks.some((network) => network.value === selectedNetwork)) {
setSelectedNetwork("ethereum");
}
};
return (<div className="flex min-h-[70vh] items-center justify-center p-4"> return (<div className="flex min-h-[70vh] items-center justify-center p-4">
<div className="flex w-full max-w-3xl flex-col items-stretch rounded-xl border bg-card shadow-sm md:flex-row"> <div className="flex w-full max-w-3xl flex-col items-stretch rounded-xl border bg-card shadow-sm md:flex-row">
<div className="flex flex-1 flex-col items-center justify-between space-y-6 border-b p-6 md:border-r md:border-b-0"> <div className="flex min-w-0 flex-1 basis-0 flex-col items-center justify-between space-y-6 border-b p-6 md:border-r md:border-b-0">
<div className="flex flex-col items-center space-y-4"> <div className="flex flex-col items-center space-y-4">
<div className="relative flex h-32 w-full items-center justify-center"> <div className="relative flex h-32 w-full items-center justify-center">
<img src={KofiLogo} className="pointer-events-none absolute w-72" alt="Ko-fi"/> <img src={KofiLogo} className="pointer-events-none absolute w-72" alt="Ko-fi"/>
@@ -20,35 +61,59 @@ export function SupportPage() {
Enjoying the project? You can support ongoing development by buying me a coffee. Enjoying the project? You can support ongoing development by buying me a coffee.
</p> </p>
</div> </div>
<Button className="h-10 w-full gap-2 bg-[#72a4f2] text-sm font-semibold text-white hover:bg-[#5f8cd6]" onClick={() => openExternal("https://ko-fi.com/afkarxyz")}> <Button className="h-9 w-4/5 gap-2 bg-[#72a4f2] text-sm font-semibold text-white hover:bg-[#5f8cd6]" onClick={() => openExternal("https://ko-fi.com/afkarxyz")}>
<img src={KofiSvg} className="h-5 w-5 shrink-0" alt="" aria-hidden="true"/> <img src={KofiSvg} className="h-6 w-6 shrink-0" alt="" aria-hidden="true"/>
Support me on Ko-fi Support me on Ko-fi
</Button> </Button>
</div> </div>
<div className="flex flex-1 flex-col items-center justify-between space-y-6 p-6"> <div className="flex min-w-0 flex-1 basis-0 flex-col items-center justify-between space-y-4 p-6">
<div className="flex w-full flex-col items-center space-y-4"> <div className="flex w-full flex-col items-center space-y-3">
<div className="flex h-32 items-center justify-center"> <div className="flex h-32 items-center justify-center">
<div className="rounded-xl border bg-white p-2 shadow-sm"> <div className="rounded-xl border bg-white p-2 shadow-sm">
<img src={UsdtBarcode} className="h-24 w-24 object-contain" alt="USDT Barcode"/> <img src={cryptoQr} className="h-24 w-24 object-contain" alt={`${selectedCoin.toUpperCase()} ${activeNetwork.label} QR code`}/>
</div> </div>
</div> </div>
<h4 className="font-semibold text-foreground">USDT (TRC20)</h4> <h4 className="font-semibold text-foreground">Support via Crypto</h4>
<p className="px-4 text-center text-sm text-muted-foreground"> <p className="px-4 text-center text-sm text-muted-foreground">
Crypto donations are also accepted. Scan the QR code or copy the address. Crypto donations are also accepted. Scan the QR code or copy the address.
</p> </p>
</div> </div>
<div className="flex h-10 w-full items-center justify-between gap-2 rounded-lg border bg-muted/50 py-1.5 pr-1.5 pl-3"> <div className="w-full space-y-2">
<code className="truncate text-xs font-mono text-muted-foreground" title={USDT_ADDRESS}> <div className="grid grid-cols-2 gap-2">
{USDT_ADDRESS} <Select value={selectedCoin} onValueChange={(value: CryptoCoin) => handleCoinChange(value)}>
</code> <SelectTrigger size="sm" className="w-full" aria-label="Coin">
<Button variant="ghost" size="icon" className="h-7 w-7 shrink-0 hover:bg-background" onClick={() => { <SelectValue />
navigator.clipboard.writeText(USDT_ADDRESS); </SelectTrigger>
setCopiedUsdt(true); <SelectContent>
setTimeout(() => setCopiedUsdt(false), 500); <SelectItem value="usdt">USDT</SelectItem>
<SelectItem value="usdc">USDC</SelectItem>
</SelectContent>
</Select>
<Select value={selectedNetwork} onValueChange={(value: CryptoNetwork) => {
setSelectedNetwork(value);
setCopiedAddress(false);
}}> }}>
{copiedUsdt ? <CircleCheck className="h-3.5 w-3.5 text-green-500"/> : <Copy className="h-3.5 w-3.5"/>} <SelectTrigger size="sm" className="w-full" aria-label="Network">
</Button> <SelectValue>{activeNetwork.shortLabel}</SelectValue>
</SelectTrigger>
<SelectContent>
{networkOptions.map((network) => (<SelectItem key={network.value} value={network.value}>{network.label}</SelectItem>))}
</SelectContent>
</Select>
</div>
<div className="flex h-10 w-full items-center justify-between gap-2 rounded-lg border bg-muted/50 py-1.5 pr-1.5 pl-3">
<code className="min-w-0 flex-1 truncate text-xs font-mono text-muted-foreground" title={cryptoAddress}>
{cryptoAddress}
</code>
<Button variant="ghost" size="icon" className="h-7 w-7 shrink-0 hover:bg-background" aria-label="Copy wallet address" onClick={() => {
navigator.clipboard.writeText(cryptoAddress);
setCopiedAddress(true);
setTimeout(() => setCopiedAddress(false), 500);
}}>
{copiedAddress ? <CircleCheck className="h-3.5 w-3.5 text-green-500"/> : <Copy className="h-3.5 w-3.5"/>}
</Button>
</div>
</div> </div>
</div> </div>
</div> </div>
+1 -1
View File
@@ -5,7 +5,7 @@ import { openExternal } from "@/lib/utils";
const INFO_LINKS = [ const INFO_LINKS = [
{ label: "Chrome Extension", icon: Puzzle, url: "https://chromewebstore.google.com/detail/cboceolmgkoobpfjiojkigmihijfgmdo" }, { label: "Chrome Extension", icon: Puzzle, url: "https://chromewebstore.google.com/detail/cboceolmgkoobpfjiojkigmihijfgmdo" },
{ label: "Userscript", icon: FileCode2, url: "https://greasyfork.org/en/scripts/523157" }, { label: "Userscript", icon: FileCode2, url: "https://greasyfork.org/en/scripts/523157" },
{ label: "Website", icon: Globe, url: "https://mediabatchdl.com" }, { label: "Website", icon: Globe, url: "https://twitterdl.app" },
]; ];
export function TitleBar() { export function TitleBar() {
const handleMinimize = () => { const handleMinimize = () => {
+1 -20
View File
@@ -1,21 +1,17 @@
import { useSyncExternalStore } from "react"; import { useSyncExternalStore } from "react";
import { EventsOn } from "../../wailsjs/runtime/runtime"; import { EventsOn } from "../../wailsjs/runtime/runtime";
export interface DownloadProgress { export interface DownloadProgress {
current: number; current: number;
total: number; total: number;
percent: number; percent: number;
} }
export interface DownloadItemStatus { export interface DownloadItemStatus {
tweet_id: number; tweet_id: number;
index: number; index: number;
status: "success" | "failed" | "skipped" | "cancelled"; status: "success" | "failed" | "skipped" | "cancelled";
} }
export type DownloadScope = "media" | "database" | "database-bulk"; export type DownloadScope = "media" | "database" | "database-bulk";
export type DownloadItemResult = "success" | "failed" | "skipped"; export type DownloadItemResult = "success" | "failed" | "skipped";
export interface DownloadState { export interface DownloadState {
active: boolean; active: boolean;
scope: DownloadScope | null; scope: DownloadScope | null;
@@ -25,9 +21,7 @@ export interface DownloadState {
itemKeyByIndex: Record<number, string>; itemKeyByIndex: Record<number, string>;
itemStatusByKey: Record<string, DownloadItemResult>; itemStatusByKey: Record<string, DownloadItemResult>;
} }
const listeners = new Set<() => void>(); const listeners = new Set<() => void>();
let state: DownloadState = { let state: DownloadState = {
active: false, active: false,
scope: null, scope: null,
@@ -37,20 +31,16 @@ let state: DownloadState = {
itemKeyByIndex: {}, itemKeyByIndex: {},
itemStatusByKey: {}, itemStatusByKey: {},
}; };
let unsubscribeEvents: (() => void) | null = null; let unsubscribeEvents: (() => void) | null = null;
function emit() { function emit() {
for (const listener of listeners) { for (const listener of listeners) {
listener(); listener();
} }
} }
function setState(next: Partial<DownloadState>) { function setState(next: Partial<DownloadState>) {
state = { ...state, ...next }; state = { ...state, ...next };
emit(); emit();
} }
export function initDownloadProgressEvents() { export function initDownloadProgressEvents() {
if (unsubscribeEvents) { if (unsubscribeEvents) {
return unsubscribeEvents; return unsubscribeEvents;
@@ -80,11 +70,7 @@ export function initDownloadProgressEvents() {
}; };
return unsubscribeEvents; return unsubscribeEvents;
} }
export function beginDownload(progress: DownloadProgress, meta: Pick<DownloadState, "scope"> & Partial<Pick<DownloadState, "accountId" | "currentItemKey" | "itemKeyByIndex">>) {
export function beginDownload(
progress: DownloadProgress,
meta: Pick<DownloadState, "scope"> & Partial<Pick<DownloadState, "accountId" | "currentItemKey" | "itemKeyByIndex">>
) {
setState({ setState({
active: true, active: true,
scope: meta.scope, scope: meta.scope,
@@ -94,7 +80,6 @@ export function beginDownload(
itemKeyByIndex: meta.itemKeyByIndex ?? {}, itemKeyByIndex: meta.itemKeyByIndex ?? {},
}); });
} }
export function finishDownload() { export function finishDownload() {
setState({ setState({
active: false, active: false,
@@ -105,7 +90,6 @@ export function finishDownload() {
itemKeyByIndex: {}, itemKeyByIndex: {},
}); });
} }
export function setDownloadItemStatus(itemKey: string, status: DownloadItemResult) { export function setDownloadItemStatus(itemKey: string, status: DownloadItemResult) {
setState({ setState({
itemStatusByKey: { itemStatusByKey: {
@@ -114,18 +98,15 @@ export function setDownloadItemStatus(itemKey: string, status: DownloadItemResul
}, },
}); });
} }
export function subscribeDownloadState(listener: () => void) { export function subscribeDownloadState(listener: () => void) {
listeners.add(listener); listeners.add(listener);
return () => { return () => {
listeners.delete(listener); listeners.delete(listener);
}; };
} }
export function getDownloadState() { export function getDownloadState() {
return state; return state;
} }
export function useDownloadState() { export function useDownloadState() {
return useSyncExternalStore(subscribeDownloadState, getDownloadState, getDownloadState); return useSyncExternalStore(subscribeDownloadState, getDownloadState, getDownloadState);
} }
+1 -1
View File
@@ -11,7 +11,7 @@
}, },
"info": { "info": {
"productName": "Twitter/X Media Batch Downloader", "productName": "Twitter/X Media Batch Downloader",
"productVersion": "4.8" "productVersion": "4.9"
}, },
"wailsjsdir": "./frontend", "wailsjsdir": "./frontend",
"assetdir": "./frontend/dist", "assetdir": "./frontend/dist",