From 3c32421b2a85512275672f297354506abcc31554 Mon Sep 17 00:00:00 2001 From: TonyBlu <101348912+TonyBlur@users.noreply.github.com> Date: Fri, 1 May 2026 09:33:45 +0800 Subject: [PATCH] Use backend download key in frontend queue/done maps --- ui/src/app/services/downloads.service.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ui/src/app/services/downloads.service.ts b/ui/src/app/services/downloads.service.ts index 2110d0e..fc48e4f 100644 --- a/ui/src/app/services/downloads.service.ts +++ b/ui/src/app/services/downloads.service.ts @@ -44,6 +44,11 @@ export class DownloadsService { configuration: Record = {}; customDirs: Record = {}; + private getDownloadKey(download: Download): string { + const maybeKey = (download as Download & { key?: string }).key; + return maybeKey && maybeKey.length > 0 ? maybeKey : download.url; + } + constructor() { this.socket.fromEvent('all') .pipe(takeUntilDestroyed()) @@ -61,25 +66,28 @@ export class DownloadsService { .pipe(takeUntilDestroyed()) .subscribe((strdata: string) => { const data: Download = JSON.parse(strdata); - this.queue.set(data.url, data); + const key = this.getDownloadKey(data); + this.queue.set(key, data); this.queueChanged.next(); }); this.socket.fromEvent('updated') .pipe(takeUntilDestroyed()) .subscribe((strdata: string) => { const data: Download = JSON.parse(strdata); - const dl: Download | undefined = this.queue.get(data.url); + const key = this.getDownloadKey(data); + const dl: Download | undefined = this.queue.get(key); data.checked = !!dl?.checked; data.deleting = !!dl?.deleting; - this.queue.set(data.url, data); + this.queue.set(key, data); this.updated.next(); }); this.socket.fromEvent('completed') .pipe(takeUntilDestroyed()) .subscribe((strdata: string) => { const data: Download = JSON.parse(strdata); - this.queue.delete(data.url); - this.done.set(data.url, data); + const key = this.getDownloadKey(data); + this.queue.delete(key); + this.done.set(key, data); this.queueChanged.next(); this.doneChanged.next(); });