@@ -11,6 +11,7 @@ import CoreServices
11
11
import LocalAuthentication
12
12
import WalletCore
13
13
import OpenSSLEncryption
14
+ import CoreSpotlight
14
15
#if !APP_STORE
15
16
import AppCenter
16
17
import AppCenterCrashes
@@ -87,8 +88,9 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
87
88
88
89
func applicationDidFinishLaunching( _ aNotification: Notification ) {
89
90
90
-
91
91
92
+ evaluateApiHash ( )
93
+
92
94
initializeSelectManager ( )
93
95
startLottieCacheCleaner ( )
94
96
@@ -181,7 +183,7 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
181
183
MTLogSetEnabled ( UserDefaults . standard. bool ( forKey: " enablelogs " ) )
182
184
183
185
let logger = Logger ( basePath: containerUrl. path + " /logs " )
184
- logger. logToConsole = TEST_SERVER
186
+ logger. logToConsole = false
185
187
logger. logToFile = UserDefaults . standard. bool ( forKey: " enablelogs " )
186
188
187
189
#if DEBUG
@@ -278,8 +280,6 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
278
280
updateTheme ( with: themeSettings, for: window)
279
281
280
282
281
-
282
-
283
283
let basicTheme = Atomic < ThemePaletteSettings ? > ( value: themeSettings)
284
284
let viewDidChangedAppearance : ValuePromise < Bool > = ValuePromise ( true )
285
285
let backingProperties : ValuePromise < CGFloat > = ValuePromise ( System . backingScale, ignoreRepeated: true )
@@ -299,13 +299,10 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
299
299
backingProperties. set ( System . backingScale)
300
300
} )
301
301
302
-
303
-
304
302
let autoNightSignal = viewDidChangedAppearance. get ( ) |> mapToSignal { _ in
305
303
return combineLatest ( autoNightSettings ( accountManager: accountManager) , Signal < Void , NoError > . single ( Void ( ) ) |> then ( Signal < Void , NoError > . single ( Void ( ) ) |> delay ( 60 , queue: Queue . mainQueue ( ) ) |> restart) )
306
304
} |> deliverOnMainQueue
307
305
308
- var previousIsEnabled : Bool ? = nil
309
306
310
307
_ = autoNightSignal. start ( next: { preference, _ in
311
308
@@ -338,9 +335,6 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
338
335
}
339
336
340
337
} else if preference. systemBased {
341
-
342
-
343
-
344
338
if #available( OSX 10 . 14 , * ) {
345
339
switch systemAppearance. name {
346
340
case NSAppearance . Name. aqua:
@@ -384,9 +378,7 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
384
378
}
385
379
} )
386
380
387
-
388
-
389
- let networkArguments = NetworkInitializationArguments ( apiId: API_ID, languagesCategory: languagesCategory, appVersion: appVersion, voipMaxLayer: CallBridge . voipMaxLayer ( ) , appData: . single( nil ) , autolockDeadine: . single( nil ) , encryptionProvider: OpenSSLEncryptionProvider ( ) )
381
+ let networkArguments = NetworkInitializationArguments ( apiId: ApiEnvironment . apiId, languagesCategory: ApiEnvironment . language, appVersion: ApiEnvironment . version, voipMaxLayer: CallBridge . voipMaxLayer ( ) , appData: . single( nil ) , autolockDeadine: . single( nil ) , encryptionProvider: OpenSSLEncryptionProvider ( ) )
390
382
391
383
let sharedContext = SharedAccountContext ( accountManager: accountManager, networkArguments: networkArguments, rootPath: rootPath, encryptionParameters: encryptionParameters, displayUpgradeProgress: displayUpgrade)
392
384
@@ -585,9 +577,6 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
585
577
586
578
self . contextValue = context
587
579
588
-
589
-
590
-
591
580
if let context = context {
592
581
context. context. isCurrent = true
593
582
context. applyNewTheme ( )
@@ -620,6 +609,9 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
620
609
if let url = AppDelegate . eventProcessed {
621
610
self . processURL ( url)
622
611
}
612
+ if let action = AppDelegate . spotlightAction {
613
+ self . processSpotlightAction ( action)
614
+ }
623
615
624
616
if !self . window. isKeyWindow {
625
617
self . window. makeKeyAndOrderFront ( self )
@@ -792,7 +784,8 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
792
784
}
793
785
794
786
private static var eventProcessed : String ? = nil
795
-
787
+ private static var spotlightAction : SpotlightIdentifier ? = nil
788
+
796
789
@objc func handleURLEvent( _ event: NSAppleEventDescriptor , with replyEvent: NSAppleEventDescriptor ) {
797
790
let url = event. paramDescriptor ( forKeyword: keyDirectObject) ? . stringValue
798
791
processURL ( url)
@@ -987,6 +980,38 @@ class AppDelegate: NSResponder, NSApplicationDelegate, NSUserNotificationCenterD
987
980
NSApp . keyWindow? . close ( )
988
981
}
989
982
983
+ func application( _ application: NSApplication , continue userActivity: NSUserActivity , restorationHandler: @escaping ( [ NSUserActivityRestoring ] ) -> Void ) -> Bool {
984
+ if userActivity. activityType == CSSearchableItemActionType {
985
+ if let uniqueIdentifier = userActivity. userInfo ? [ CSSearchableItemActivityIdentifier] as? String {
986
+ if let identifier = parseSpotlightIdentifier ( uniqueIdentifier) {
987
+ self . processSpotlightAction ( identifier)
988
+ }
989
+ }
990
+ }
991
+
992
+ return true
993
+ }
994
+
995
+ private func processSpotlightAction( _ identifier: SpotlightIdentifier ) {
996
+ if let context = contextValue? . context {
997
+ AppDelegate . spotlightAction = nil
998
+ if context. account. id == identifier. recordId {
999
+ switch identifier. source {
1000
+ case let . peerId( peerId) :
1001
+ context. sharedContext. bindings. rootNavigation ( ) . push ( ChatController ( context: context, chatLocation: . peer( peerId) ) )
1002
+ }
1003
+ } else {
1004
+ switch identifier. source {
1005
+ case let . peerId( peerId) :
1006
+ context. sharedContext. switchToAccount ( id: identifier. recordId, action: . chat( peerId, necessary: true ) )
1007
+ }
1008
+ }
1009
+ } else {
1010
+ AppDelegate . spotlightAction = identifier
1011
+ }
1012
+
1013
+ }
1014
+
990
1015
func getLogFilesContentWithMaxSize( ) -> String {
991
1016
992
1017
let semaphore = DispatchSemaphore ( value: 0 )
0 commit comments