@@ -71,13 +71,14 @@ fileprivate final class AccountInfoArguments {
71
71
let openPremium : ( Bool ) -> Void
72
72
let giftPremium : ( ) -> Void
73
73
let stars : ( ) -> Void
74
+ let ton : ( ) -> Void
74
75
let addAccount : ( [ AccountWithInfo ] ) -> Void
75
76
let setStatus : ( Control , TelegramUser ) -> Void
76
77
let runStatusPopover : ( ) -> Void
77
78
let set2Fa : ( TwoStepVeriticationAccessConfiguration ? ) -> Void
78
79
let openStory : ( StoryInitialIndex ? ) -> Void
79
80
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 ) {
81
82
self . context = context
82
83
self . storyList = storyList
83
84
self . presentController = presentController
@@ -93,6 +94,7 @@ fileprivate final class AccountInfoArguments {
93
94
self . openStory = openStory
94
95
self . openWebBot = openWebBot
95
96
self . stars = stars
97
+ self . ton = ton
96
98
}
97
99
}
98
100
@@ -146,7 +148,8 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
146
148
case premium( index: Int , viewType: GeneralViewType )
147
149
case business( index: Int , viewType: GeneralViewType )
148
150
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 )
150
153
case about( index: Int , viewType: GeneralViewType )
151
154
case faq( index: Int , viewType: GeneralViewType )
152
155
case ask( index: Int , viewType: GeneralViewType )
@@ -201,14 +204,16 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
201
204
return . index( 20 )
202
205
case . stars:
203
206
return . index( 21 )
204
- case . faq :
207
+ case . ton :
205
208
return . index( 22 )
206
- case . ask :
209
+ case . faq :
207
210
return . index( 23 )
208
- case . about :
211
+ case . ask :
209
212
return . index( 24 )
213
+ case . about:
214
+ return . index( 25 )
210
215
case let . attach( index, _, _) :
211
- return . index( 25 + index)
216
+ return . index( 26 + index)
212
217
case let . whiteSpace( index, _) :
213
218
return . index( 1000 + index)
214
219
}
@@ -264,6 +269,8 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
264
269
return index
265
270
case let . stars( index, _, _) :
266
271
return index
272
+ case let . ton( index, _, _) :
273
+ return index
267
274
case let . faq( index, _) :
268
275
return index
269
276
case let . ask( index, _) :
@@ -420,7 +427,9 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
420
427
case let . giftPremium( _, viewType) :
421
428
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 ) )
422
429
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 ) )
424
433
case let . faq( _, viewType) :
425
434
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 ) )
426
435
case let . ask( _, viewType) :
@@ -474,7 +483,7 @@ private enum AccountInfoEntry : TableItemListNodeEntry {
474
483
}
475
484
476
485
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 ] {
478
487
var entries : [ AccountInfoEntry ] = [ ]
479
488
480
489
var index : Int = 0
@@ -635,8 +644,13 @@ private func accountInfoEntries(peerView:PeerView, context: AccountContext, acco
635
644
636
645
let stars_purchase_blocked = context. appConfiguration. getBoolValue ( " stars_purchase_blocked " , orElse: true )
637
646
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) )
640
654
index += 1
641
655
}
642
656
@@ -997,6 +1011,8 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
997
1011
openWebBot ( bot, context: context)
998
1012
} , stars: {
999
1013
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)
1000
1016
} )
1001
1017
1002
1018
self . arguments = arguments
@@ -1057,8 +1073,8 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
1057
1073
} ) )
1058
1074
1059
1075
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) }
1062
1078
var size = atomicSize. modify { $0}
1063
1079
size. width = max ( size. width, 280 )
1064
1080
return prepareEntries ( left: previous. swap ( entries) , right: entries, arguments: arguments, initialSize: size)
@@ -1192,6 +1208,9 @@ class AccountViewController : TelegramGenericViewController<AccountControllerVie
1192
1208
}
1193
1209
return . invokeNext
1194
1210
} , with: self , for: . Escape, priority: . low)
1211
+
1212
+ context. starsContext. load ( force: true )
1213
+ context. tonContext. load ( force: true )
1195
1214
}
1196
1215
1197
1216
override func viewWillDisappear( _ animated: Bool ) {
0 commit comments