Switch to SPUUpdater and establish our own single instance of this updater in the app delegate. If we're building for App Store or a TEST build, don't even initialize Sparkle.
This commit is contained in:
parent
e80a5f92bb
commit
471c8ce667
|
@ -13,14 +13,14 @@ import RSTree
|
|||
import RSWeb
|
||||
import Account
|
||||
import RSCore
|
||||
#if TEST
|
||||
#if !MAC_APP_STORE && !TEST
|
||||
import Sparkle
|
||||
#endif
|
||||
|
||||
var appDelegate: AppDelegate!
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, UNUserNotificationCenterDelegate, UnreadCountProvider {
|
||||
class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, UNUserNotificationCenterDelegate, UnreadCountProvider, SPUStandardUserDriverDelegate, SPUUpdaterDelegate {
|
||||
|
||||
var userNotificationManager: UserNotificationManager!
|
||||
var faviconDownloader: FaviconDownloader!
|
||||
|
@ -70,6 +70,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||
private let log = Log()
|
||||
private let appNewsURLString = "https://nnw.ranchero.com/feed.json"
|
||||
private let appMovementMonitor = RSAppMovementMonitor()
|
||||
#if !MAC_APP_STORE && !TEST
|
||||
private var softwareUpdater: SPUUpdater!
|
||||
#endif
|
||||
|
||||
override init() {
|
||||
NSWindow.allowsAutomaticWindowTabbing = false
|
||||
|
@ -117,16 +120,24 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||
|
||||
func applicationWillFinishLaunching(_ notification: Notification) {
|
||||
installAppleEventHandlers()
|
||||
#if TEST
|
||||
// Don't prompt for updates while running automated tests
|
||||
SUUpdater.shared()?.automaticallyChecksForUpdates = false
|
||||
#endif
|
||||
}
|
||||
|
||||
func applicationDidFinishLaunching(_ note: Notification) {
|
||||
|
||||
#if MAC_APP_STORE
|
||||
#if MAC_APP_STORE || TEST
|
||||
checkForUpdatesMenuItem.isHidden = true
|
||||
#else
|
||||
// Initialize Sparkle...
|
||||
let hostBundle = Bundle.main
|
||||
let updateDriver = SPUStandardUserDriver(hostBundle: hostBundle, delegate: self)
|
||||
self.softwareUpdater = SPUUpdater(hostBundle: hostBundle, applicationBundle: hostBundle, userDriver: updateDriver, delegate: self)
|
||||
|
||||
do {
|
||||
try self.softwareUpdater.start()
|
||||
}
|
||||
catch {
|
||||
NSLog("Failed to start software updater with error: \(error)")
|
||||
}
|
||||
#endif
|
||||
|
||||
appName = (Bundle.main.infoDictionary!["CFBundleExecutable"]! as! String)
|
||||
|
@ -571,7 +582,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||
@IBAction func groupByFeedToggled(_ sender: NSMenuItem) {
|
||||
AppDefaults.timelineGroupByFeed.toggle()
|
||||
}
|
||||
|
||||
|
||||
@IBAction func checkForUpdates(_ sender: Any?) {
|
||||
#if !MAC_APP_STORE && !TEST
|
||||
self.softwareUpdater.checkForUpdates()
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Debug Menu
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<menuItem title="Check for Updates…" id="1nF-7O-aKU">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="checkForUpdates:" target="5Wg-Cw-OOw" id="vV0-oc-v5a"/>
|
||||
<action selector="checkForUpdates:" target="Ady-hI-5gd" id="htt-e3-mEy"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
|
||||
|
@ -623,7 +623,6 @@
|
|||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
<customObject id="5Wg-Cw-OOw" customClass="SUUpdater"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-54" y="-144"/>
|
||||
</scene>
|
||||
|
|
|
@ -234,17 +234,7 @@
|
|||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="1hh-8U-B8b" name="value" keyPath="automaticallyChecksForUpdates" id="cge-fo-09y">
|
||||
<dictionary key="options">
|
||||
<bool key="NSAllowsEditingMultipleValuesSelection" value="NO"/>
|
||||
<bool key="NSConditionallySetsEnabled" value="NO"/>
|
||||
<integer key="NSMultipleValuesPlaceholder" value="0"/>
|
||||
<integer key="NSNoSelectionPlaceholder" value="0"/>
|
||||
<integer key="NSNotApplicablePlaceholder" value="0"/>
|
||||
<integer key="NSNullPlaceholder" value="0"/>
|
||||
<bool key="NSRaisesForNotApplicableKeys" value="NO"/>
|
||||
</dictionary>
|
||||
</binding>
|
||||
<binding destination="mV3-0T-XFc" name="value" keyPath="values.SUEnableAutomaticChecks" id="PwC-5l-EQR"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Q6M-Iz-Ypx">
|
||||
|
@ -293,7 +283,7 @@
|
|||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="checkForUpdates:" target="1hh-8U-B8b" id="RX4-6c-Osn"/>
|
||||
<action selector="checkForUpdates:" target="VX1-M3-K0J" id="WVQ-XY-Czt"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField horizontalHuggingPriority="1000" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="SUN-k3-ZEb">
|
||||
|
@ -382,8 +372,8 @@
|
|||
</connections>
|
||||
</viewController>
|
||||
<customObject id="VX1-M3-K0J" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
<customObject id="1hh-8U-B8b" customClass="SUUpdater"/>
|
||||
<userDefaultsController id="Y8q-yi-F5Z"/>
|
||||
<userDefaultsController id="mV3-0T-XFc"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-29" y="455.5"/>
|
||||
</scene>
|
||||
|
|
Loading…
Reference in New Issue