Skip to content

Commit fc82f6d

Browse files
authored
Merge pull request XcodesOrg#821 from XcodesOrg/matt/fixMultipleDownloadNotifications
fix: multiple download notifications
2 parents 9bca2e2 + fbde813 commit fc82f6d

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

Xcodes/Backend/AppState+Install.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,17 @@ extension AppState {
129129
if let expectedInstallationTaskID, self.installationTaskIDs[availableXcode.xcodeID] != expectedInstallationTaskID {
130130
return
131131
}
132-
self.setInstallationStep(of: availableXcode.version, to: .downloading(progress: progress))
132+
133+
let isAlreadyDownloading: Bool
134+
if let xcode = self.allXcodes.first(where: { $0.version.isEquivalent(to: availableXcode.version) }),
135+
case .installing(.downloading) = xcode.installState
136+
{
137+
isAlreadyDownloading = true
138+
} else {
139+
isAlreadyDownloading = false
140+
}
141+
142+
self.setInstallationStep(of: availableXcode.version, to: .downloading(progress: progress), postNotification: !isAlreadyDownloading)
133143
self.addDockProgressChildIfNeeded(progress, withPendingUnitCount: AppState.totalProgressUnits - AppState.unxipProgressWeight)
134144
}
135145
})
@@ -455,12 +465,14 @@ extension AppState {
455465

456466
// MARK: -
457467

458-
func setInstallationStep(of version: Version, to step: XcodeInstallationStep) {
468+
func setInstallationStep(of version: Version, to step: XcodeInstallationStep, postNotification: Bool = true) {
459469
guard let index = allXcodes.firstIndex(where: { $0.version.isEquivalent(to: version) }) else { return }
460470
allXcodes[index].installState = .installing(step)
461471

462472
let xcode = allXcodes[index]
463-
Current.notificationManager.scheduleNotification(title: xcode.version.major.description + "." + xcode.version.appleDescription, body: step.description, category: .normal)
473+
if postNotification {
474+
Current.notificationManager.scheduleNotification(title: xcode.version.major.description + "." + xcode.version.appleDescription, body: step.description, category: .normal)
475+
}
464476
}
465477

466478
func setInstallationStep(of runtime: DownloadableRuntime, to step: RuntimeInstallationStep, postNotification: Bool = true) {

0 commit comments

Comments
 (0)