Skip to content

Commit

Permalink
Add missing SPARKLE checks
Browse files Browse the repository at this point in the history
  • Loading branch information
quanganhdo committed Sep 25, 2024
1 parent 92c756a commit 3f91338
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,12 @@ final class MoreOptionsMenu: NSMenu, NSMenuDelegate {
}

func menuWillOpen(_ menu: NSMenu) {
#if SPARKLE
guard let updateController = Application.appDelegate.updateController else { return }
if updateController.hasPendingUpdate && updateController.needsNotificationDot {
updateController.needsNotificationDot = false
}
#endif
}
}

Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/NavigationBar/View/MoreOptionsMenuButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ final class MoreOptionsMenuButton: MouseOverButton {
}

private func subscribeToUpdateInfo() {
#if SPARKLE
guard let updateController else { return }
cancellable = Publishers.CombineLatest(updateController.hasPendingUpdatePublisher, updateController.notificationDotPublisher)
.receive(on: DispatchQueue.main)
.sink { [weak self] hasPendingUpdate, needsNotificationDot in
self?.isNotificationVisible = hasPendingUpdate && needsNotificationDot
}
#endif
}

private func setupNotificationLayerIfNeeded() {
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/Preferences/Model/AboutPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ final class AboutPreferences: ObservableObject, PreferencesTabOpening {

@Published var updateState = UpdateState.upToDate

#if SPARKLE
var updateController: UpdateControllerProtocol? {
return Application.appDelegate.updateController
}
#endif

var areAutomaticUpdatesEnabled: Bool {
get {
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/Preferences/View/PreferencesAboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ extension Preferences {
}
}

#if SPARKLE
private var hasPendingUpdate: Bool {
model.updateController?.hasPendingUpdate == true
}
#endif

@ViewBuilder
private var versionText: some View {
Expand Down

0 comments on commit 3f91338

Please sign in to comment.