feat: stop every download at once
A stop button appears beside Download all whenever anything is
downloading or waiting to, and disappears when nothing is. It kills the
running processes, marks everything the database still calls queued or
running as cancelled, and clears the part files. Downloads already
finished are untouched.
That also covers two cases a per-video Cancel cannot reach: a download
parked on a slot, which stands down when its turn comes, and a row left
"running" by a crash that no process backs any more.
Cancelling no longer reports itself as a failure. download_video
returned Err("Download was cancelled.") when it found its child gone,
which the caller turned into an error dialog — pressing Stop all would
have raised one per download. Stopping something is a normal outcome:
the state is already recorded and the event already sent, so it returns
cleanly.
This commit is contained in:
@@ -23,6 +23,9 @@ interface Props {
|
||||
onDeleteAll?: () => void;
|
||||
/** Present only on a channel page with videos still to fetch. */
|
||||
onDownloadAll?: () => void;
|
||||
/** Present only while something is downloading or waiting to. */
|
||||
onStopAll?: () => void;
|
||||
stopAllCount?: number;
|
||||
/** How many this press would queue, and how many are listed in all. */
|
||||
downloadAllCount?: number;
|
||||
downloadAllTotal?: number;
|
||||
@@ -64,7 +67,7 @@ export default function TopBar({
|
||||
online, reachable, forcedOffline, onToggleForcedOffline,
|
||||
onRefresh, refreshing, refreshProgress, resultCount, view, onView,
|
||||
sidebarHidden, onShowSidebar, onDeleteAll, onDownloadAll, downloadAllCount = 0,
|
||||
downloadAllTotal = 0, titleBarInset,
|
||||
downloadAllTotal = 0, onStopAll, stopAllCount = 0, titleBarInset,
|
||||
}: Props) {
|
||||
const pct = refreshProgress && refreshProgress.total > 0
|
||||
? (refreshProgress.done / refreshProgress.total) * 100
|
||||
@@ -111,6 +114,25 @@ export default function TopBar({
|
||||
Local
|
||||
</Toggle>
|
||||
|
||||
{onStopAll && (
|
||||
<button
|
||||
onClick={onStopAll}
|
||||
title={`Stop the ${stopAllCount} download${
|
||||
stopAllCount === 1 ? "" : "s"
|
||||
} in progress — nothing already saved is deleted`}
|
||||
aria-label="Stop all downloads"
|
||||
className={`${ICON_BTN} border border-slate-300 text-slate-500 hover:border-red-500
|
||||
hover:text-red-600 dark:border-slate-700 dark:text-slate-400
|
||||
dark:hover:border-red-500 dark:hover:text-red-400`}
|
||||
>
|
||||
<svg viewBox="0 0 24 24" className="size-4" fill="none" stroke="currentColor"
|
||||
strokeWidth="1.8">
|
||||
<circle cx="12" cy="12" r="8.5" />
|
||||
<rect x="9" y="9" width="6" height="6" rx="1" fill="currentColor" stroke="none" />
|
||||
</svg>
|
||||
</button>
|
||||
)}
|
||||
|
||||
{onDownloadAll && (
|
||||
<button
|
||||
onClick={onDownloadAll}
|
||||
|
||||
Reference in New Issue
Block a user