@@ -22,9 +22,14 @@ import InAppPurchaseManager
2222import ApiCredentials
2323
2424let clown : String = " 🤡 "
25+ let focusIntentEmoji = " ⛔️ "
2526
2627
2728
29+ func bestWindow( _ accountContext: AccountContext , _ controller: ViewController ? ) -> Window {
30+ return controller? . window ?? accountContext. window
31+ }
32+
2833public struct PremiumConfiguration {
2934 public static var defaultValue : PremiumConfiguration {
3035 return PremiumConfiguration (
@@ -169,6 +174,13 @@ extension AppConfiguration {
169174 return defaultValue
170175 }
171176 }
177+ func getStringValue( _ key: String , orElse defaultValue: String ) -> String {
178+ if let value = self . data ? [ key] as? String {
179+ return value
180+ } else {
181+ return defaultValue
182+ }
183+ }
172184 func getBoolValue( _ key: String , orElse defaultValue: Bool ) -> Bool {
173185 if let value = self . data ? [ key] as? Bool {
174186 return value
@@ -325,12 +337,12 @@ final class AccountContextBindings {
325337 let rootNavigation : ( ) -> MajorNavigationController
326338 let mainController : ( ) -> MainViewController
327339 let showControllerToaster : ( ControllerToaster , Bool ) -> Void
328- let globalSearch : ( String ) -> Void
340+ let globalSearch : ( String , PeerId ? ) -> Void
329341 let switchSplitLayout : ( SplitViewState ) -> Void
330342 let entertainment : ( ) -> EntertainmentViewController
331343 let needFullsize : ( ) -> Void
332344 let displayUpgradeProgress : ( CGFloat ) -> Void
333- init ( rootNavigation: @escaping ( ) -> MajorNavigationController = { fatalError ( ) } , mainController: @escaping ( ) -> MainViewController = { fatalError ( ) } , showControllerToaster: @escaping ( ControllerToaster , Bool ) -> Void = { _, _ in fatalError ( ) } , globalSearch: @escaping ( String ) -> Void = { _ in fatalError ( ) } , entertainment: @escaping ( ) -> EntertainmentViewController = { fatalError ( ) } , switchSplitLayout: @escaping ( SplitViewState ) -> Void = { _ in fatalError ( ) } , needFullsize: @escaping ( ) -> Void = { fatalError ( ) } , displayUpgradeProgress: @escaping ( CGFloat ) -> Void = { _ in fatalError ( ) } ) {
345+ init ( rootNavigation: @escaping ( ) -> MajorNavigationController = { fatalError ( ) } , mainController: @escaping ( ) -> MainViewController = { fatalError ( ) } , showControllerToaster: @escaping ( ControllerToaster , Bool ) -> Void = { _, _ in fatalError ( ) } , globalSearch: @escaping ( String , PeerId ? ) -> Void = { _ , _ in fatalError ( ) } , entertainment: @escaping ( ) -> EntertainmentViewController = { fatalError ( ) } , switchSplitLayout: @escaping ( SplitViewState ) -> Void = { _ in fatalError ( ) } , needFullsize: @escaping ( ) -> Void = { fatalError ( ) } , displayUpgradeProgress: @escaping ( CGFloat ) -> Void = { _ in fatalError ( ) } ) {
334346 self . rootNavigation = rootNavigation
335347 self . mainController = mainController
336348 self . showControllerToaster = showControllerToaster
@@ -362,6 +374,7 @@ final class AccountContext {
362374 let cachedGroupCallContexts : AccountGroupCallContextCacheImpl
363375 let networkStatusManager : NetworkStatusManager
364376 let inAppPurchaseManager : InAppPurchaseManager
377+ let starsContext : StarsContext
365378
366379 #endif
367380 private( set) var timeDifference : TimeInterval = 0
@@ -597,7 +610,8 @@ final class AccountContext {
597610 self . networkStatusManager = NetworkStatusManager ( account: account, window: window, sharedContext: sharedContext)
598611 self . reactions = Reactions ( engine)
599612 self . dockControl = DockControl ( engine, accountManager: sharedContext. accountManager)
600- #endif
613+ self . starsContext = engine. payments. peerStarsContext ( )
614+ #endif
601615
602616
603617 giftStickersValues. set ( engine. stickers. loadedStickerPack ( reference: . premiumGifts, forceActualized: false )
@@ -916,6 +930,46 @@ final class AccountContext {
916930
917931 actionsDisposable. add ( requestApplicationIcons ( engine: engine) . start ( ) )
918932
933+ // let focusIntentStatus = someAccountSetings(postbox: account.postbox)
934+ // |> distinctUntilChanged(isEqual: {
935+ // $0.focusIntentStatusEnabled == $1.focusIntentStatusEnabled &&
936+ // $0.focusIntentStatusActive == $1.focusIntentStatusActive
937+ // })
938+ // |> deliverOnMainQueue
939+ //
940+ // actionsDisposable.add(focusIntentStatus.startStandalone(next: { [weak self] settings in
941+ // guard let self else {
942+ // return
943+ // }
944+ // let setStatus:(Int64?)->Void = { [weak self] fileId in
945+ // guard let self else {
946+ // return
947+ // }
948+ // if let fileId {
949+ // let file = self.inlinePacksContext.load(fileId: fileId) |> deliverOnMainQueue
950+ // _ = file.startStandalone(next: { file in
951+ // _ = engine.accountData.setEmojiStatus(file: file, expirationDate: nil).start()
952+ // })
953+ // } else {
954+ // _ = engine.accountData.setEmojiStatus(file: nil, expirationDate: nil).start()
955+ // }
956+ // }
957+ // if settings.focusIntentStatusEnabled {
958+ // if let fileId = settings.focusIntentStatusActive {
959+ // setStatus(fileId)
960+ // } else {
961+ // _ = (self.diceCache.top_emojies_status |> deliverOnMainQueue).startStandalone(next: { files in
962+ // if let file = files.first(where: { $0.customEmojiText == focusIntentEmoji }) {
963+ // setStatus(file.fileId.id)
964+ // }
965+ // })
966+ // }
967+ // } else if let fileId = settings.focusIntentStatusFallback {
968+ // setStatus(fileId)
969+ // } else {
970+ // setStatus(nil)
971+ // }
972+ // }))
919973
920974 #endif
921975
0 commit comments