@@ -101,7 +101,8 @@ public struct PremiumConfiguration {
101101 minGroupCustomWallpaperLevel: 9 ,
102102 minGroupEmojiPackLevel: 9 ,
103103 minGroupAudioTranscriptionLevel: 9 ,
104- minChannelWearGiftLevel: 8
104+ minChannelWearGiftLevel: 8 ,
105+ minChannelAutotranslationLevel: 3
105106 )
106107 }
107108
@@ -129,7 +130,7 @@ public struct PremiumConfiguration {
129130 public let minGroupCustomWallpaperLevel : Int32
130131 public let minGroupEmojiPackLevel : Int32
131132 public let minGroupAudioTranscriptionLevel : Int32
132-
133+ public let minChannelAutotranslationLevel : Int32
133134 fileprivate init (
134135 isPremiumDisabled: Bool ,
135136 showPremiumGiftInAttachMenu: Bool ,
@@ -152,7 +153,8 @@ public struct PremiumConfiguration {
152153 minGroupCustomWallpaperLevel: Int32 ,
153154 minGroupEmojiPackLevel: Int32 ,
154155 minGroupAudioTranscriptionLevel: Int32 ,
155- minChannelWearGiftLevel: Int32
156+ minChannelWearGiftLevel: Int32 ,
157+ minChannelAutotranslationLevel: Int32
156158 ) {
157159 self . isPremiumDisabled = isPremiumDisabled
158160 self . showPremiumGiftInAttachMenu = showPremiumGiftInAttachMenu
@@ -176,6 +178,7 @@ public struct PremiumConfiguration {
176178 self . minGroupEmojiPackLevel = minGroupEmojiPackLevel
177179 self . minGroupAudioTranscriptionLevel = minGroupAudioTranscriptionLevel
178180 self . minChannelWearGiftLevel = minChannelWearGiftLevel
181+ self . minChannelAutotranslationLevel = minChannelAutotranslationLevel
179182 }
180183
181184 public static func with( appConfiguration: AppConfiguration ) -> PremiumConfiguration {
@@ -206,7 +209,8 @@ public struct PremiumConfiguration {
206209 minGroupCustomWallpaperLevel: get ( data [ " group_custom_wallpaper_level_min " ] ) ?? defaultValue. minGroupCustomWallpaperLevel,
207210 minGroupEmojiPackLevel: get ( data [ " group_emoji_stickers_level_min " ] ) ?? defaultValue. minGroupEmojiPackLevel,
208211 minGroupAudioTranscriptionLevel: get ( data [ " group_transcribe_level_min " ] ) ?? defaultValue. minGroupAudioTranscriptionLevel,
209- minChannelWearGiftLevel: get ( data [ " channel_emoji_status_level_min " ] ) ?? defaultValue. minChannelWearGiftLevel
212+ minChannelWearGiftLevel: get ( data [ " channel_emoji_status_level_min " ] ) ?? defaultValue. minChannelWearGiftLevel,
213+ minChannelAutotranslationLevel: get ( data [ " channel_autotranslation_level_min " ] ) ?? defaultValue. minChannelWearGiftLevel
210214 )
211215 } else {
212216 return defaultValue
@@ -226,6 +230,20 @@ extension AppConfiguration {
226230 return defaultValue
227231 }
228232 }
233+ func getGeneralValue64( _ key: String , orElse defaultValue: Int64 ) -> Int64 {
234+ if let value = self . data ? [ key] as? Double {
235+ return Int64 ( value)
236+ } else {
237+ return defaultValue
238+ }
239+ }
240+ func getGeneralValueDouble( _ key: String , orElse defaultValue: Double ) -> Double {
241+ if let value = self . data ? [ key] as? Double {
242+ return Double ( value)
243+ } else {
244+ return defaultValue
245+ }
246+ }
229247 func getStringValue( _ key: String , orElse defaultValue: String ) -> String {
230248 if let value = self . data ? [ key] as? String {
231249 return value
@@ -303,8 +321,12 @@ enum ChatLocation: Equatable {
303321
304322extension ChatLocation {
305323
306- static func makeSaved( _ accountPeerId: PeerId , peerId: PeerId ) -> ChatLocation {
307- return . thread( . init( peerId: accountPeerId, threadId: peerId. toInt64 ( ) , channelMessageId: nil , isChannelPost: false , isForumPost: false , maxMessage: nil , maxReadIncomingMessageId: nil , maxReadOutgoingMessageId: nil , unreadCount: 0 , initialFilledHoles: IndexSet ( ) , initialAnchor: . automatic, isNotAvailable: false ) )
324+ static func makeSaved( _ accountPeerId: PeerId , peerId: PeerId , isMonoforum: Bool = false ) -> ChatLocation {
325+ return . makeSaved( accountPeerId, threadId: peerId. toInt64 ( ) , isMonoforum: isMonoforum)
326+ }
327+
328+ static func makeSaved( _ accountPeerId: PeerId , threadId: Int64 , isMonoforum: Bool = false ) -> ChatLocation {
329+ return . thread( . init( peerId: accountPeerId, threadId: threadId, channelMessageId: nil , isChannelPost: false , isForumPost: false , isMonoforumPost: isMonoforum, maxMessage: nil , maxReadIncomingMessageId: nil , maxReadOutgoingMessageId: nil , unreadCount: 0 , initialFilledHoles: IndexSet ( ) , initialAnchor: . automatic, isNotAvailable: false ) )
308330 }
309331
310332 var unreadMessageCountsItem : UnreadMessageCountsItem {
@@ -432,13 +454,23 @@ final class AccountContext {
432454 let networkStatusManager : NetworkStatusManager
433455 let inAppPurchaseManager : InAppPurchaseManager
434456 let starsContext : StarsContext
457+ let tonContext : StarsContext
435458 let starsSubscriptionsContext : StarsSubscriptionsContext
436459 let currentCountriesConfiguration : Atomic < CountriesConfiguration > = Atomic ( value: CountriesConfiguration ( countries: loadCountryCodes ( ) ) )
437- private ( set ) var contentConfig : ContentSettingsConfiguration = . default
460+ var contentConfig : ContentSettingsConfiguration = . default
438461 private let _countriesConfiguration = Promise < CountriesConfiguration > ( )
439462 var countriesConfiguration : Signal < CountriesConfiguration , NoError > {
440463 return self . _countriesConfiguration. get ( )
441464 }
465+
466+ func currencyContext( _ currency: CurrencyAmount . Currency ) -> StarsContext {
467+ switch currency {
468+ case . stars:
469+ return starsContext
470+ case . ton:
471+ return tonContext
472+ }
473+ }
442474
443475 #endif
444476 private( set) var timeDifference : TimeInterval = 0
@@ -684,6 +716,7 @@ final class AccountContext {
684716 self . reactions = Reactions ( engine)
685717 self . dockControl = DockControl ( engine, accountManager: sharedContext. accountManager)
686718 self . starsContext = engine. payments. peerStarsContext ( )
719+ self . tonContext = engine. payments. peerTonContext ( )
687720 self . starsSubscriptionsContext = engine. payments. peerStarsSubscriptionsContext ( starsContext: self . starsContext)
688721
689722 _ = self . engine. payments. keepStarGiftsUpdated ( ) . start ( )
@@ -1253,7 +1286,7 @@ final class AccountContext {
12531286 case let . peer( peerId) :
12541287 return . peer( peerId: peerId, threadId: nil )
12551288 case let . thread( data) :
1256- if data. isForumPost || data. peerId. namespace != Namespaces . Peer. CloudChannel {
1289+ if data. isForumPost || data. peerId. namespace != Namespaces . Peer. CloudChannel || data . isMonoforumPost {
12571290 return . peer( peerId: data. peerId, threadId: data. threadId)
12581291 } else {
12591292 let context = chatLocationContext ( holder: contextHolder, account: self . account, data: data)
@@ -1357,7 +1390,7 @@ final class AccountContext {
13571390 } else {
13581391 updatedMode = . replies( origin: fromId)
13591392 }
1360- let controller = ChatController ( context: context, chatLocation: chatLocation, mode: . thread( data : result . message , mode: updatedMode) , focusTarget: . init( messageId: fromId) , initialAction: nil , chatLocationContextHolder: result. contextHolder)
1393+ let controller = ChatController ( context: context, chatLocation: chatLocation, mode: . thread( mode: updatedMode) , focusTarget: . init( messageId: fromId) , initialAction: nil , chatLocationContextHolder: result. contextHolder)
13611394
13621395 context. bindings. rootNavigation ( ) . push ( controller)
13631396
@@ -1643,7 +1676,7 @@ private func chatLocationContext(holder: Atomic<ChatLocationContextHolder?>, acc
16431676 } else {
16441677 return ChatLocationContextHolderImpl ( account: account, data: data)
16451678 }
1646- } as! ChatLocationContextHolderImpl
1679+ } as! ChatLocationContextHolderImpl
16471680 return holder. context
16481681}
16491682
0 commit comments