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: implement cancellation for generic downloads with error handling

Tonho4a6127357ea1
diff --git a/src/routes/downloads/+page.svelte b/src/routes/downloads/+page.svelte
index 5338d45f..cc243fb0 100644
--- a/src/routes/downloads/+page.svelte
+++ b/src/routes/downloads/+page.svelte
@@ -31,6 +31,15 @@
}
}
+ async function cancelGenericDownload(id: number) {
+ try {
+ await invoke("cancel_generic_download", { downloadId: id });
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? "Error";
+ showToast("error", msg);
+ }
+ }
+
</script>
{#if hasDownloads}
@@ -44,9 +53,22 @@
<PlatformIcon platform={item.platform} size={16} />
<span class="item-name">{item.name}</span>
</div>
- <span class="item-status" data-status={item.status}>
- {$t(`downloads.status.${item.status}`)}
- </span>
+ <div class="item-header-actions">
+ {#if item.status === "downloading"}
+ <button
+ class="cancel-btn"
+ onclick={() => cancelGenericDownload(item.id)}
+ aria-label={$t('downloads.cancel')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ </button>
+ {/if}
+ <span class="item-status" data-status={item.status}>
+ {$t(`downloads.status.${item.status}`)}
+ </span>
+ </div>
</div>
<span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>