diff --git a/iTorrent/Services/LiveActivityService/LiveActivityService.swift b/iTorrent/Services/LiveActivityService/LiveActivityService.swift index 53007f01..c5c28949 100644 --- a/iTorrent/Services/LiveActivityService/LiveActivityService.swift +++ b/iTorrent/Services/LiveActivityService/LiveActivityService.swift @@ -94,7 +94,7 @@ private extension LiveActivityService { { return } if #available(iOS 16.2, *) { - await activity.update(.init(state: state, staleDate: .now + 10)) + await activity.update(.init(state: state, staleDate: .now + 10, relevanceScore: state.state.relevanceScore)) } else { await activity.update(using: state) } @@ -122,6 +122,29 @@ private extension LiveActivityService { } } +private extension ProgressWidgetAttributes.State { + var relevanceScore: Double { + switch self { + case .checkingFiles: + 2 + case .downloadingMetadata: + 3 + case .downloading: + 5 + case .finished: + 0 + case .seeding: + 4 + case .checkingResumeData: + 1 + case .paused: + 0 + case .storageError: + 0 + } + } +} + private extension TorrentHandle.Snapshot { var toLiveActivityState: ProgressWidgetAttributes.ContentState { let color = PreferencesStorage.shared.tintColor