mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Initialize Sparkle based on UserDefaults
This commit is contained in:
parent
a169265707
commit
30b3a446d7
@ -2,12 +2,23 @@ import Cocoa
|
||||
import Sparkle
|
||||
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
SUUpdater.shared()?.automaticallyChecksForUpdates = true
|
||||
/*
|
||||
Next line prints:
|
||||
⚠️ You must specify the URL of the appcast as the SUFeedURL key in either the Info.plist or the user defaults!
|
||||
*/
|
||||
SUUpdater.shared()?.checkForUpdates(self)
|
||||
func applicationWillFinishLaunching(_ notification: Notification) {
|
||||
// Check UserDefaults for values; if the key doesn't exist (e.g., if MacUpdatesView hasn't ever been shown),
|
||||
// bool(forKey:) returns false, so set SUUpdater.shared() appropriately.
|
||||
let automaticallyChecksForUpdates = UserDefaults.standard.bool(forKey: "automaticallyChecksForUpdates")
|
||||
let subscribeToBetaUpdates = UserDefaults.standard.bool(forKey: "subscribeToBetaUpdates")
|
||||
|
||||
// Set Sparkle properties.
|
||||
SUUpdater.shared()?.automaticallyChecksForUpdates = automaticallyChecksForUpdates
|
||||
if subscribeToBetaUpdates {
|
||||
SUUpdater.shared()?.feedURL = URL(string: AppcastFeedUrl.beta.rawValue)
|
||||
} else {
|
||||
SUUpdater.shared()?.feedURL = URL(string: AppcastFeedUrl.release.rawValue)
|
||||
}
|
||||
|
||||
// If enabled, check for updates.
|
||||
if automaticallyChecksForUpdates {
|
||||
SUUpdater.shared()?.checkForUpdates(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import SwiftUI
|
||||
import Sparkle
|
||||
|
||||
private enum AppcastFeedUrl: String {
|
||||
enum AppcastFeedUrl: String {
|
||||
case release = "https://files.writefreely.org/apps/mac/appcast.xml"
|
||||
case beta = "https://files.writefreely.org/apps/mac/appcast-beta.xml"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user