@@ -71,13 +71,14 @@ fileprivate final class AccountInfoArguments {
7171 let openPremium : ( Bool ) -> Void
7272 let giftPremium : ( ) -> Void
7373 let stars : ( ) -> Void
74+ let ton : ( ) -> Void
7475 let addAccount : ( [ AccountWithInfo ] ) -> Void
7576 let setStatus : ( Control , TelegramUser ) -> Void
7677 let runStatusPopover : ( ) -> Void
7778 let set2Fa : ( TwoStepVeriticationAccessConfiguration ? ) -> Void
7879 let openStory : ( StoryInitialIndex ? ) -> Void
7980 let openWebBot : ( AttachMenuBot ) -> Void
80- init ( context: AccountContext , storyList: PeerStoryListContext , presentController: @escaping ( ViewController , Bool ) -> Void , openFaq: @escaping ( ) -> Void , ask: @escaping ( ) -> Void , openUpdateApp: @escaping ( ) -> Void , openPremium: @escaping ( Bool ) -> Void , giftPremium: @escaping ( ) -> Void , addAccount: @escaping ( [ AccountWithInfo ] ) -> Void , setStatus: @escaping ( Control , TelegramUser ) -> Void , runStatusPopover: @escaping ( ) -> Void , set2Fa: @escaping ( TwoStepVeriticationAccessConfiguration ? ) -> Void , openStory: @escaping ( StoryInitialIndex ? ) -> Void , openWebBot: @escaping ( AttachMenuBot ) -> Void , stars: @escaping ( ) -> Void ) {
81+ init ( context: AccountContext , storyList: PeerStoryListContext , presentController: @escaping ( ViewController , Bool ) -> Void , openFaq: @escaping ( ) -> Void , ask: @escaping ( ) -> Void , openUpdateApp: @escaping ( ) -> Void , openPremium: @escaping ( Bool ) -> Void , giftPremium: @escaping ( ) -> Void , addAccount: @escaping ( [ AccountWithInfo ] ) -> Void , setStatus: @escaping ( Control , TelegramUser ) -> Void , runStatusPopover: @escaping ( ) -> Void , set2Fa: @escaping ( TwoStepVeriticationAccessConfiguration ? ) -> Void , openStory: @escaping ( StoryInitialIndex ? ) -> Void , openWebBot: @escaping ( AttachMenuBot ) -> Void , stars: @escaping ( ) -> Void , ton : @escaping ( ) -> Void ) {
8182 self . context = context
8283 self . storyList = storyList
8384 self . presentController = presentController
@@ -93,6 +94,7 @@ fileprivate final class AccountInfoArguments {
9394 self . openStory = openStory
9495 self . openWebBot = openWebBot
9596 self . stars = stars
97+ self . ton = ton
9698 }
9799}
98100
@@ -146,7 +148,8 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
146148 case premium( index: Int , viewType: GeneralViewType )
147149 case business( index: Int , viewType: GeneralViewType )
148150 case giftPremium( index: Int , viewType: GeneralViewType )
149- case stars( index: Int , count: Int64 , viewType: GeneralViewType )
151+ case stars( index: Int , count: StarsAmount , viewType: GeneralViewType )
152+ case ton( index: Int , count: StarsAmount , viewType: GeneralViewType )
150153 case about( index: Int , viewType: GeneralViewType )
151154 case faq( index: Int , viewType: GeneralViewType )
152155 case ask( index: Int , viewType: GeneralViewType )
@@ -201,14 +204,16 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
201204 return . index( 20 )
202205 case . stars:
203206 return . index( 21 )
204- case . faq :
207+ case . ton :
205208 return . index( 22 )
206- case . ask :
209+ case . faq :
207210 return . index( 23 )
208- case . about :
211+ case . ask :
209212 return . index( 24 )
213+ case . about:
214+ return . index( 25 )
210215 case let . attach( index, _, _) :
211- return . index( 25 + index)
216+ return . index( 26 + index)
212217 case let . whiteSpace( index, _) :
213218 return . index( 1000 + index)
214219 }
@@ -264,6 +269,8 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
264269 return index
265270 case let . stars( index, _, _) :
266271 return index
272+ case let . ton( index, _, _) :
273+ return index
267274 case let . faq( index, _) :
268275 return index
269276 case let . ask( index, _) :
@@ -420,7 +427,9 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
420427 case let . giftPremium( _, viewType) :
421428 return GeneralInteractedRowItem ( initialSize, stableId: stableId, name: strings ( ) . accountSettingsSendGift, icon: theme. icons. settingsGiftPremium, activeIcon: theme. icons. settingsGiftPremium, type: . next, viewType: viewType, action: arguments. giftPremium, border: [ BorderType . Right] , inset: NSEdgeInsets ( left: 12 , right: 12 ) )
422429 case let . stars( _, stars, viewType) :
423- return GeneralInteractedRowItem ( initialSize, stableId: stableId, name: strings ( ) . accountSettingsStars, icon: theme. icons. settingsStars, activeIcon: theme. icons. settingsStars, type: . nextContext( stars > 0 ? " \( stars) " : " " ) , viewType: viewType, action: arguments. stars, border: [ BorderType . Right] , inset: NSEdgeInsets ( left: 12 , right: 12 ) )
430+ return GeneralInteractedRowItem ( initialSize, stableId: stableId, name: strings ( ) . accountSettingsStars, icon: theme. icons. settingsStars, activeIcon: theme. icons. settingsStars, type: . nextContext( stars. value > 0 ? " \( stars. stringValue) " : " " ) , viewType: viewType, action: arguments. stars, border: [ BorderType . Right] , inset: NSEdgeInsets ( left: 12 , right: 12 ) )
431+ case let . ton( _, ton, viewType) :
432+ return GeneralInteractedRowItem ( initialSize, stableId: stableId, name: strings ( ) . accountSettingsTon, icon: theme. icons. settingsWallet, activeIcon: theme. icons. settingsWalletActive, type: . nextContext( ton. value > 0 ? " \( ton. string ( . ton) ) " : " " ) , viewType: viewType, action: arguments. ton, border: [ BorderType . Right] , inset: NSEdgeInsets ( left: 12 , right: 12 ) )
424433 case let . faq( _, viewType) :
425434 return GeneralInteractedRowItem ( initialSize, stableId: stableId, name: strings ( ) . accountSettingsFAQ, icon: theme. icons. settingsFaq, activeIcon: theme. icons. settingsFaqActive, type: . next, viewType: viewType, action: arguments. openFaq, border: [ BorderType . Right] , inset: NSEdgeInsets ( left: 12 , right: 12 ) )
426435 case let . ask( _, viewType) :
@@ -474,7 +483,7 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
474483}
475484
476485
477- private func accountInfoEntries( peerView: PeerView , context: AccountContext , accounts: [ AccountWithInfo ] , language: TelegramLocalization , privacySettings: AccountPrivacySettings ? , webSessions: WebSessionsContextState , proxySettings: ( ProxySettings , ConnectionStatus ) , passportVisible: Bool , appUpdateState: Any ? , hasFilters: Bool , sessionsCount: Int , unAuthStatus: UNUserNotifications . AuthorizationStatus , has2fa: Bool , twoStepConfiguration: TwoStepVeriticationAccessConfiguration ? , storyStats: EngineStorySubscriptions ? , attachMenuBots: [ AttachMenuBot ] , stars: StarsContext . State ? ) -> [ AccountInfoEntry ] {
486+ private func accountInfoEntries( peerView: PeerView , context: AccountContext , accounts: [ AccountWithInfo ] , language: TelegramLocalization , privacySettings: AccountPrivacySettings ? , webSessions: WebSessionsContextState , proxySettings: ( ProxySettings , ConnectionStatus ) , passportVisible: Bool , appUpdateState: Any ? , hasFilters: Bool , sessionsCount: Int , unAuthStatus: UNUserNotifications . AuthorizationStatus , has2fa: Bool , twoStepConfiguration: TwoStepVeriticationAccessConfiguration ? , storyStats: EngineStorySubscriptions ? , attachMenuBots: [ AttachMenuBot ] , stars: StarsContext . State ? , ton : StarsContext . State ? ) -> [ AccountInfoEntry ] {
478487 var entries : [ AccountInfoEntry ] = [ ]
479488
480489 var index : Int = 0
@@ -635,8 +644,13 @@ private func accountInfoEntries(peerView:PeerView, context: AccountContext, acco
635644
636645 let stars_purchase_blocked = context. appConfiguration. getBoolValue ( " stars_purchase_blocked " , orElse: true )
637646
638- if !stars_purchase_blocked, let stars, stars. balance. value > 0 || !stars. transactions. isEmpty {
639- entries. append ( . stars( index: index, count: stars. balance. value, viewType: . singleItem) )
647+ if !stars_purchase_blocked, let stars {
648+ entries. append ( . stars( index: index, count: stars. balance, viewType: . singleItem) )
649+ index += 1
650+ }
651+
652+ if let ton, ton. balance. value > 0 || !ton. transactions. isEmpty {
653+ entries. append ( . ton( index: index, count: ton. balance, viewType: . singleItem) )
640654 index += 1
641655 }
642656
@@ -997,6 +1011,8 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
9971011 openWebBot ( bot, context: context)
9981012 } , stars: {
9991013 showModal ( with: Star_ListScreen ( context: context, source: . account) , for: context. window)
1014+ } , ton: {
1015+ showModal ( with: Star_ListScreen ( context: context, currency: . ton, source: . account) , for: context. window)
10001016 } )
10011017
10021018 self . arguments = arguments
@@ -1057,8 +1073,8 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
10571073 } ) )
10581074
10591075
1060- let apply = combineLatest ( queue: prepareQueue, context. account. viewTracker. peerView ( context. account. peerId) , context. sharedContext. activeAccountsWithInfo, appearanceSignal, settings. get ( ) , appUpdateState, hasFilters. get ( ) , sessionsCount, UNUserNotifications . recurrentAuthorizationStatus ( context) , twoStep, storyStats, acceptBots. get ( ) , context. starsContext. state) |> map { peerView, accounts, appearance, settings, appUpdateState, hasFilters, sessionsCount, unAuthStatus, twoStepConfiguration, storyStats, attachMenuBots, stars -> TableUpdateTransition in
1061- let entries = accountInfoEntries ( peerView: peerView, context: context, accounts: accounts. accounts, language: appearance. language, privacySettings: settings. 0 , webSessions: settings. 1 , proxySettings: settings. 2 , passportVisible: settings. 3 . 0 , appUpdateState: appUpdateState, hasFilters: hasFilters, sessionsCount: sessionsCount, unAuthStatus: unAuthStatus, has2fa: settings. 3 . 1 , twoStepConfiguration: twoStepConfiguration, storyStats: storyStats, attachMenuBots: attachMenuBots, stars: stars) . map { AppearanceWrapperEntry ( entry: $0, appearance: appearance) }
1076+ let apply = combineLatest ( queue: prepareQueue, context. account. viewTracker. peerView ( context. account. peerId) , context. sharedContext. activeAccountsWithInfo, appearanceSignal, settings. get ( ) , appUpdateState, hasFilters. get ( ) , sessionsCount, UNUserNotifications . recurrentAuthorizationStatus ( context) , twoStep, storyStats, acceptBots. get ( ) , context. starsContext. state, context . tonContext . state ) |> map { peerView, accounts, appearance, settings, appUpdateState, hasFilters, sessionsCount, unAuthStatus, twoStepConfiguration, storyStats, attachMenuBots, stars, ton -> TableUpdateTransition in
1077+ let entries = accountInfoEntries ( peerView: peerView, context: context, accounts: accounts. accounts, language: appearance. language, privacySettings: settings. 0 , webSessions: settings. 1 , proxySettings: settings. 2 , passportVisible: settings. 3 . 0 , appUpdateState: appUpdateState, hasFilters: hasFilters, sessionsCount: sessionsCount, unAuthStatus: unAuthStatus, has2fa: settings. 3 . 1 , twoStepConfiguration: twoStepConfiguration, storyStats: storyStats, attachMenuBots: attachMenuBots, stars: stars, ton : ton ) . map { AppearanceWrapperEntry ( entry: $0, appearance: appearance) }
10621078 var size = atomicSize. modify { $0}
10631079 size. width = max ( size. width, 280 )
10641080 return prepareEntries ( left: previous. swap ( entries) , right: entries, arguments: arguments, initialSize: size)
@@ -1192,6 +1208,9 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
11921208 }
11931209 return . invokeNext
11941210 } , with: self , for: . Escape, priority: . low)
1211+
1212+ context. starsContext. load ( force: true )
1213+ context. tonContext. load ( force: true )
11951214 }
11961215
11971216 override func viewWillDisappear( _ animated: Bool ) {
0 commit comments