feat: cancel playlist adding mid-operation (closes #840)

This commit is contained in:
ddmoney420
2026-03-01 19:11:29 -07:00
parent fd3aaea9d9
commit 880eda8435
5 changed files with 39 additions and 11 deletions

View File

@@ -98,15 +98,17 @@
name="addUrl"
[(ngModel)]="addUrl"
[disabled]="addInProgress || downloads.loading">
<button class="btn btn-primary btn-lg px-4"
type="submit"
(click)="addDownload()"
[disabled]="addInProgress || downloads.loading">
@if (addInProgress) {
<span class="spinner-border spinner-border-sm" role="status" id="add-spinner"></span>
}
{{ addInProgress ? "Adding..." : "Download" }}
</button>
@if (addInProgress) {
<button class="btn btn-danger btn-lg px-3" type="button" (click)="cancelAdding()">
<fa-icon [icon]="faTimesCircle" class="me-1" /> Cancel
</button>
} @else {
<button class="btn btn-primary btn-lg px-4" type="submit"
(click)="addDownload()"
[disabled]="downloads.loading">
Download
</button>
}
</div>
</div>
</div>

View File

@@ -433,6 +433,13 @@ export class App implements AfterViewInit, OnInit {
});
}
cancelAdding() {
this.downloads.cancelAdd().subscribe({
next: () => { this.addInProgress = false; },
error: () => { this.addInProgress = false; }
});
}
downloadItemByKey(id: string) {
this.downloads.startById([id]).subscribe();
}

View File

@@ -208,6 +208,9 @@ export class DownloadsService {
public exportQueueUrls(): string[] {
return Array.from(this.queue.values()).map(download => download.url);
}
public cancelAdd() {
return this.http.post<any>('cancel-add', {}).pipe(
catchError(this.handleHTTPError)
);
}
}