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.

fix: add listener for queue item progress updates and handle progress data

Tonho3b5c3cc746f5
diff --git a/src/lib/stores/download-listener.ts b/src/lib/stores/download-listener.ts
index eefc33af..687cd4db 100644
--- a/src/lib/stores/download-listener.ts
+++ b/src/lib/stores/download-listener.ts
@@ -5,6 +5,7 @@ import {
upsertProgress,
markComplete,
syncQueueState,
+ upsertGenericProgress,
} from "./download-store.svelte";
import { showToast } from "./toast-store.svelte";
import {
@@ -63,6 +64,17 @@ export function onBatchFileStatus(cb: BatchFileStatusCallback | null) {
batchFileStatusCallback = cb;
}
+type QueueItemProgressPayload = {
+ id: number;
+ title: string;
+ platform: string;
+ percent: number;
+ speed_bytes_per_sec: number;
+ downloaded_bytes: number;
+ total_bytes: number | null;
+ eta_seconds: number | null;
+};
+
type ConvertProgressPayload = {
id: number;
percent: number;
@@ -127,6 +139,23 @@ export async function initDownloadListener(): Promise<() => void> {
},
);
+ const unlistenQueueItemProgress = await listen<QueueItemProgressPayload>(
+ "queue-item-progress",
+ (event) => {
+ const d = event.payload;
+ upsertGenericProgress(
+ d.id,
+ d.title,
+ d.platform,
+ d.percent,
+ d.speed_bytes_per_sec,
+ d.downloaded_bytes,
+ d.total_bytes,
+ d.eta_seconds,
+ );
+ },
+ );
+
const unlistenBatchFileStatus = await listen<BatchFileStatusPayload>(
"telegram-batch-file-status",
(event) => {
@@ -163,6 +192,7 @@ export async function initDownloadListener(): Promise<() => void> {
unlistenProgress();
unlistenComplete();
unlistenQueueState();
+ unlistenQueueItemProgress();
unlistenBatchFileStatus();
unlistenConvertProgress();
unlistenConvertComplete();