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 functions to clear finished downloads and count completed items

Tonhod7228664e9cd
diff --git a/src/lib/stores/download-store.svelte.ts b/src/lib/stores/download-store.svelte.ts
index 6184780a..047f9748 100644
--- a/src/lib/stores/download-store.svelte.ts
+++ b/src/lib/stores/download-store.svelte.ts
@@ -116,6 +116,27 @@ export function markComplete(courseName: string, success: boolean, error?: strin
}
}
+export function clearFinished() {
+ let changed = false;
+ for (const [id, item] of downloads) {
+ if (item.status !== "downloading") {
+ downloads.delete(id);
+ changed = true;
+ }
+ }
+ if (changed) {
+ downloads = new Map(downloads);
+ }
+}
+
+export function getFinishedCount(): number {
+ let count = 0;
+ for (const item of downloads.values()) {
+ if (item.status !== "downloading") count++;
+ }
+ return count;
+}
+
export function upsertGenericProgress(
id: number,
title: string,