@@ -17,15 +17,7 @@ import RSCoreResources
17
17
import Secrets
18
18
import OSLog
19
19
import CrashReporter
20
-
21
- // If we're not going to import Sparkle, provide dummy protocols to make it easy
22
- // for AppDelegate to comply
23
- #if MAC_APP_STORE || TEST
24
- protocol SPUStandardUserDriverDelegate { }
25
- protocol SPUUpdaterDelegate { }
26
- #else
27
20
import Sparkle
28
- #endif
29
21
30
22
var appDelegate : AppDelegate !
31
23
@@ -100,22 +92,18 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
100
92
private var inspectorWindowController : InspectorWindowController ?
101
93
private var crashReportWindowController : CrashReportWindowController ? // For testing only
102
94
private let appMovementMonitor = RSAppMovementMonitor ( )
103
- #if !MAC_APP_STORE && !TEST
104
95
private var softwareUpdater : SPUUpdater !
105
96
private var crashReporter : PLCrashReporter !
106
- #endif
107
-
97
+
108
98
private var themeImportPath : String ?
109
99
110
100
override init ( ) {
111
101
NSWindow . allowsAutomaticWindowTabbing = false
112
102
super. init ( )
113
103
114
- #if !MAC_APP_STORE
115
104
let crashReporterConfig = PLCrashReporterConfig . defaultConfiguration ( )
116
105
crashReporter = PLCrashReporter ( configuration: crashReporterConfig)
117
106
crashReporter. enable ( )
118
- #endif
119
107
120
108
AccountManager . shared = AccountManager ( accountsFolder: Platform . dataSubfolder ( forApplication: nil , folderName: " Accounts " ) !)
121
109
ArticleThemesManager . shared = ArticleThemesManager ( folderPath: Platform . dataSubfolder ( forApplication: nil , folderName: " Themes " ) !)
@@ -171,22 +159,18 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
171
159
172
160
func applicationDidFinishLaunching( _ note: Notification ) {
173
161
174
- #if MAC_APP_STORE || TEST
175
- checkForUpdatesMenuItem. isHidden = true
176
- #else
177
- // Initialize Sparkle...
178
- let hostBundle = Bundle . main
179
- let updateDriver = SPUStandardUserDriver ( hostBundle: hostBundle, delegate: self )
180
- self . softwareUpdater = SPUUpdater ( hostBundle: hostBundle, applicationBundle: hostBundle, userDriver: updateDriver, delegate: self )
162
+ // Initialize Sparkle...
163
+ let hostBundle = Bundle . main
164
+ let updateDriver = SPUStandardUserDriver ( hostBundle: hostBundle, delegate: self )
165
+ self . softwareUpdater = SPUUpdater ( hostBundle: hostBundle, applicationBundle: hostBundle, userDriver: updateDriver, delegate: self )
166
+
167
+ do {
168
+ try self . softwareUpdater. start ( )
169
+ }
170
+ catch {
171
+ NSLog ( " Failed to start software updater with error: \( error) " )
172
+ }
181
173
182
- do {
183
- try self . softwareUpdater. start ( )
184
- }
185
- catch {
186
- NSLog ( " Failed to start software updater with error: \( error) " )
187
- }
188
- #endif
189
-
190
174
AppDefaults . shared. registerDefaults ( )
191
175
let isFirstRun = AppDefaults . shared. isFirstRun
192
176
if isFirstRun {
@@ -258,25 +242,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
258
242
}
259
243
#endif
260
244
261
- if AppDefaults . shared. showDebugMenu {
262
- // The Web Inspector uses SPI and can never appear in a MAC_APP_STORE build.
263
- #if MAC_APP_STORE
264
- let debugMenu = debugMenuItem. submenu!
265
- let toggleWebInspectorItemIndex = debugMenu. indexOfItem ( withTarget: self , andAction: #selector( toggleWebInspectorEnabled ( _: ) ) )
266
- if toggleWebInspectorItemIndex != - 1 {
267
- debugMenu. removeItem ( at: toggleWebInspectorItemIndex)
268
- }
269
- #endif
270
- } else {
245
+ if !AppDefaults. shared. showDebugMenu {
271
246
debugMenuItem. menu? . removeItem ( debugMenuItem)
272
247
}
273
248
274
- #if !MAC_APP_STORE
275
249
DispatchQueue . main. async {
276
250
CrashReporter . check ( crashReporter: self . crashReporter)
277
251
}
278
- #endif
279
-
280
252
}
281
253
282
254
func application( _ application: NSApplication , continue userActivity: NSUserActivity , restorationHandler: @escaping ( [ NSUserActivityRestoring ] ) -> Void ) -> Bool {
@@ -456,12 +428,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
456
428
return !isDisplayingSheet && !AccountManager. shared. activeAccounts. isEmpty
457
429
}
458
430
459
- #if !MAC_APP_STORE
460
431
if item. action == #selector( toggleWebInspectorEnabled ( _: ) ) {
461
432
( item as! NSMenuItem ) . state = AppDefaults . shared. webInspectorEnabled ? . on : . off
462
433
}
463
- #endif
464
-
434
+
465
435
return true
466
436
}
467
437
@@ -682,11 +652,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
682
652
}
683
653
684
654
@IBAction func checkForUpdates( _ sender: Any ? ) {
685
- #if !MAC_APP_STORE && !TEST
686
- self . softwareUpdater. checkForUpdates ( )
687
- #endif
655
+ self . softwareUpdater. checkForUpdates ( )
688
656
}
689
-
690
657
}
691
658
692
659
// MARK: - Debug Menu
@@ -728,18 +695,16 @@ extension AppDelegate {
728
695
}
729
696
730
697
@IBAction func toggleWebInspectorEnabled( _ sender: Any ? ) {
731
- #if !MAC_APP_STORE
698
+
732
699
let newValue = !AppDefaults. shared. webInspectorEnabled
733
700
AppDefaults . shared. webInspectorEnabled = newValue
734
701
735
- // An attached inspector can display incorrectly on certain setups (like mine); default to displaying in a separate window,
736
- // and reset the default to a separate window when the preference is toggled off and on again in case the inspector is
737
- // accidentally reattached.
702
+ // An attached inspector can display incorrectly on certain setups (like mine); default to displaying in a separate window,
703
+ // and reset the default to a separate window when the preference is toggled off and on again in case the inspector is
704
+ // accidentally reattached.
738
705
AppDefaults . shared. webInspectorStartsAttached = false
739
- NotificationCenter . default. post ( name: . WebInspectorEnabledDidChange, object: newValue)
740
- #endif
706
+ NotificationCenter . default. post ( name: . WebInspectorEnabledDidChange, object: newValue)
741
707
}
742
-
743
708
}
744
709
745
710
internal extension AppDelegate {
0 commit comments