-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b4f231
commit 4a57986
Showing
10 changed files
with
173 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
AppleMusicDiscordRPC/AppleMusicDiscordRPC/Modals/SparkleObservable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import SwiftUI | ||
import Sparkle | ||
|
||
// Adapted from: | ||
// https://github.com/writefreely/writefreely-swiftui-multiplatform/blob/main/macOS/Settings/MacUpdatesViewModel.swift | ||
|
||
class SparkleObservable: ObservableObject { | ||
@Published var canCheckForUpdates: Bool = true | ||
private let updaterController: SPUStandardUpdaterController | ||
|
||
var automaticallyCheckForUpdates: Bool { | ||
get { | ||
return updaterController.updater.automaticallyChecksForUpdates | ||
} | ||
set(newValue) { | ||
updaterController.updater.automaticallyChecksForUpdates = newValue | ||
} | ||
} | ||
|
||
init() { | ||
self.updaterController = SPUStandardUpdaterController( | ||
startingUpdater: true, | ||
updaterDelegate: nil, | ||
userDriverDelegate: nil | ||
) | ||
|
||
self.updaterController.updater.publisher(for: \.canCheckForUpdates) | ||
.assign(to: &self.$canCheckForUpdates) | ||
|
||
if self.automaticallyCheckForUpdates { | ||
self.updaterController.updater.checkForUpdatesInBackground() | ||
} | ||
} | ||
|
||
func checkForUpdates() { | ||
updaterController.checkForUpdates(nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.