feat: improve queue management

This commit is contained in:
nimbold
2026-06-02 05:12:23 +03:30
parent ac039a50c8
commit fd6457ddc5
4 changed files with 174 additions and 33 deletions
+17 -5
View File
@@ -239,7 +239,7 @@ struct DownloadTable: View {
}
.onDrag {
draggedItemID = item.id
return NSItemProvider(object: item.id.uuidString as NSString)
return NSItemProvider(object: dragPayload(for: item) as NSString)
}
.onDrop(
of: [.text],
@@ -361,10 +361,15 @@ struct DownloadTable: View {
}
}
if targetItems.contains(where: { $0.status != .downloading && $0.status != .queued }) {
Button {
for target in targetItems where target.status != .downloading && target.status != .queued {
controller.queue(target)
if targetItems.contains(where: { $0.status != .completed && $0.status != .downloading }) {
Menu {
ForEach(controller.queues) { queue in
Button(queue.name) {
controller.assignToQueue(
itemIDs: Set(targetItems.map(\.id)),
queueID: queue.id
)
}
}
} label: {
Label("Add to Queue", systemImage: "list.bullet")
@@ -482,6 +487,13 @@ struct DownloadTable: View {
return index + 1
}
private func dragPayload(for item: DownloadItem) -> String {
let draggedIDs = selection.contains(item.id) ? selection : [item.id]
return draggedIDs
.map(\.uuidString)
.joined(separator: "\n")
}
private func compare<T: Comparable>(_ lhs: T, _ rhs: T) -> ComparisonResult {
if lhs < rhs { return .orderedAscending }
if lhs > rhs { return .orderedDescending }