Skip to content

Commit

Permalink
Live activity order improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Nov 30, 2024
1 parent 6c5c24b commit 1ae5281
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion iTorrent/Services/LiveActivityService/LiveActivityService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1ae5281

Please sign in to comment.