Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: add download cancellation functionality with UI integration

Tonho897ce468b0cd
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index f61b709e..9369cc78 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -5,6 +5,7 @@
import Mascot from "$components/mascot/Mascot.svelte";
import { getDownloads, removeDownload, type GenericDownloadItem } from "$lib/stores/download-store.svelte";
import { getSettings } from "$lib/stores/settings-store.svelte";
+ import { showToast } from "$lib/stores/toast-store.svelte";
import { t } from "$lib/i18n";
type PlatformInfo = {
@@ -213,6 +214,18 @@
url = "";
}
+ async function handleCancelDownload() {
+ if (omniState.kind !== "downloading") return;
+ const trackingId = omniState.trackingId;
+ try {
+ await invoke("cancel_generic_download", { downloadId: trackingId });
+ } catch {
+ }
+ removeDownload(trackingId);
+ omniState = { kind: "idle" };
+ url = "";
+ }
+
async function handleRevealFile() {
if (omniState.kind !== "complete" || !omniState.filePath) return;
try {
@@ -305,6 +318,12 @@
style="width: {(trackedDownload?.percent ?? 0).toFixed(1)}%"
></div>
</div>
+ <div class="card-row card-actions">
+ <span class="card-subtext">{$t('omnibox.preparing')}</span>
+ <button class="button card-action-btn" onclick={handleCancelDownload}>
+ {$t('downloads.cancel')}
+ </button>
+ </div>
</div>
{:else if omniState.kind === "complete"}