mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Various improvements
This commit is contained in:
@@ -247,6 +247,9 @@ public final class AccountContextImpl: AccountContext {
|
||||
private var peerNameColorsConfigurationDisposable: Disposable?
|
||||
public private(set) var peerNameColors: PeerNameColors
|
||||
|
||||
private var audioTranscriptionTrialDisposable: Disposable?
|
||||
public private(set) var audioTranscriptionTrial: AudioTranscription.TrialState
|
||||
|
||||
public private(set) var isPremium: Bool
|
||||
|
||||
public let imageCache: AnyObject?
|
||||
@@ -261,6 +264,7 @@ public final class AccountContextImpl: AccountContext {
|
||||
|
||||
self.userLimits = EngineConfiguration.UserLimits(UserLimitsConfiguration.defaultValue)
|
||||
self.peerNameColors = PeerNameColors.defaultValue
|
||||
self.audioTranscriptionTrial = AudioTranscription.TrialState.defaultValue
|
||||
self.isPremium = false
|
||||
|
||||
self.downloadedMediaStoreManager = DownloadedMediaStoreManagerImpl(postbox: account.postbox, accountManager: sharedContext.accountManager)
|
||||
@@ -414,6 +418,22 @@ public final class AccountContextImpl: AccountContext {
|
||||
}
|
||||
self.peerNameColors = PeerNameColors.with(appConfiguration: appConfiguration)
|
||||
})
|
||||
|
||||
self.audioTranscriptionTrialDisposable = (self.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: account.peerId))
|
||||
|> mapToSignal { peer -> Signal<AudioTranscription.TrialState, NoError> in
|
||||
let isPremium = peer?.isPremium ?? false
|
||||
if isPremium {
|
||||
return .single(AudioTranscription.TrialState(cooldownUntilTime: nil, remainingCount: 1))
|
||||
} else {
|
||||
return self.engine.data.subscribe(TelegramEngine.EngineData.Item.Configuration.AudioTranscriptionTrial())
|
||||
}
|
||||
}
|
||||
|> deliverOnMainQueue).startStrict(next: { [weak self] audioTranscriptionTrial in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
self.audioTranscriptionTrial = audioTranscriptionTrial
|
||||
})
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -703,11 +723,6 @@ private final class ChatLocationReplyContextHolderImpl: ChatLocationContextHolde
|
||||
}
|
||||
}
|
||||
|
||||
func getAppConfiguration(transaction: Transaction) -> AppConfiguration {
|
||||
let appConfiguration: AppConfiguration = transaction.getPreferencesEntry(key: PreferencesKeys.appConfiguration)?.get(AppConfiguration.self) ?? AppConfiguration.defaultValue
|
||||
return appConfiguration
|
||||
}
|
||||
|
||||
func getAppConfiguration(postbox: Postbox) -> Signal<AppConfiguration, NoError> {
|
||||
return postbox.preferencesView(keys: [PreferencesKeys.appConfiguration])
|
||||
|> map { view -> AppConfiguration in
|
||||
|
||||
Reference in New Issue
Block a user