mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
Add dock progress indicator
in .bar style
This commit is contained in:
parent
ff73109f06
commit
ec41e4ab49
2 changed files with 13 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ import AppleAPI
|
|||
import Version
|
||||
import LegibleError
|
||||
import os.log
|
||||
import DockProgress
|
||||
|
||||
/// Downloads and installs Xcodes
|
||||
extension AppState {
|
||||
|
|
@ -119,6 +120,7 @@ extension AppState {
|
|||
cookies
|
||||
)
|
||||
progressChanged(progress)
|
||||
updateDockIcon(withProgress: progress)
|
||||
return publisher
|
||||
.map { _ in destination.url }
|
||||
.eraseToAnyPublisher()
|
||||
|
|
@ -128,11 +130,12 @@ extension AppState {
|
|||
let resumeDataPath = Path.xcodesApplicationSupport/"Xcode-\(availableXcode.version).resumedata"
|
||||
let persistedResumeData = Current.files.contents(atPath: resumeDataPath.string)
|
||||
|
||||
return attemptResumableTask(maximumRetryCount: 3) { resumeData -> AnyPublisher<URL, Error> in
|
||||
return attemptResumableTask(maximumRetryCount: 3) { [weak self] resumeData -> AnyPublisher<URL, Error> in
|
||||
let (progress, publisher) = Current.network.downloadTask(with: availableXcode.url,
|
||||
to: destination.url,
|
||||
resumingWith: resumeData ?? persistedResumeData)
|
||||
progressChanged(progress)
|
||||
self?.updateDockIcon(withProgress: progress)
|
||||
return publisher
|
||||
.map { $0.saveLocation }
|
||||
.eraseToAnyPublisher()
|
||||
|
|
@ -142,6 +145,11 @@ extension AppState {
|
|||
})
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
private func updateDockIcon(withProgress progress: Progress) {
|
||||
DockProgress.style = .bar
|
||||
DockProgress.progressInstance = progress
|
||||
}
|
||||
|
||||
public func installArchivedXcode(_ availableXcode: AvailableXcode, at archiveURL: URL) -> AnyPublisher<InstalledXcode, Error> {
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import LegibleError
|
|||
import KeychainAccess
|
||||
import Path
|
||||
import Version
|
||||
import DockProgress
|
||||
|
||||
class AppState: ObservableObject {
|
||||
private let client = AppleAPI.Client()
|
||||
|
|
@ -298,6 +299,9 @@ class AppState: ObservableObject {
|
|||
|
||||
// Cancel the publisher
|
||||
installationPublishers[id] = nil
|
||||
|
||||
// Remove dock icon progress indicator
|
||||
DockProgress.progress = 1 // Only way to completely remove overlay with DockProgress is setting progress to complete
|
||||
|
||||
// If the download is cancelled by the user, clean up the download files that aria2 creates.
|
||||
// This isn't done as part of the publisher with handleEvents(receiveCancel:) because it shouldn't happen when e.g. the app quits.
|
||||
|
|
|
|||
Loading…
Reference in a new issue