mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Voice Chat Improvements
This commit is contained in:
@@ -65,6 +65,26 @@ func contextQueryResultStateForChatInterfacePresentationState(_ chatPresentation
|
||||
return updates
|
||||
}
|
||||
|
||||
struct StickersSearchConfiguration {
|
||||
static var defaultValue: StickersSearchConfiguration {
|
||||
return StickersSearchConfiguration(disableLocalSuggestions: false)
|
||||
}
|
||||
|
||||
public let disableLocalSuggestions: Bool
|
||||
|
||||
fileprivate init(disableLocalSuggestions: Bool) {
|
||||
self.disableLocalSuggestions = disableLocalSuggestions
|
||||
}
|
||||
|
||||
static func with(appConfiguration: AppConfiguration) -> StickersSearchConfiguration {
|
||||
if let data = appConfiguration.data, let suggestOnlyApi = data["stickers_emoji_suggest_only_api"] as? Bool {
|
||||
return StickersSearchConfiguration(disableLocalSuggestions: suggestOnlyApi)
|
||||
} else {
|
||||
return .defaultValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func updatedContextQueryResultStateForQuery(context: AccountContext, peer: Peer, chatLocation: ChatLocation, inputQuery: ChatPresentationInputQuery, previousQuery: ChatPresentationInputQuery?, requestBotLocationStatus: @escaping (PeerId) -> Void) -> Signal<(ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult?, ChatContextQueryError> {
|
||||
switch inputQuery {
|
||||
case let .emoji(query):
|
||||
@@ -79,18 +99,30 @@ private func updatedContextQueryResultStateForQuery(context: AccountContext, pee
|
||||
} else {
|
||||
signal = .single({ _ in return .stickers([]) })
|
||||
}
|
||||
let stickers: Signal<(ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult?, ChatContextQueryError> = context.sharedContext.accountManager.transaction { transaction -> StickerSettings in
|
||||
|
||||
let stickerConfiguration = context.account.postbox.preferencesView(keys: [PreferencesKeys.appConfiguration])
|
||||
|> map { preferencesView -> StickersSearchConfiguration in
|
||||
let appConfiguration: AppConfiguration = preferencesView.values[PreferencesKeys.appConfiguration] as? AppConfiguration ?? .defaultValue
|
||||
return StickersSearchConfiguration.with(appConfiguration: appConfiguration)
|
||||
}
|
||||
let stickerSettings = context.sharedContext.accountManager.transaction { transaction -> StickerSettings in
|
||||
let stickerSettings: StickerSettings = (transaction.getSharedData(ApplicationSpecificSharedDataKeys.stickerSettings) as? StickerSettings) ?? .defaultSettings
|
||||
return stickerSettings
|
||||
}
|
||||
|
||||
let stickers: Signal<(ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult?, ChatContextQueryError> = combineLatest(stickerConfiguration, stickerSettings)
|
||||
|> castError(ChatContextQueryError.self)
|
||||
|> mapToSignal { stickerSettings -> Signal<[FoundStickerItem], ChatContextQueryError> in
|
||||
|> mapToSignal { stickerConfiguration, stickerSettings -> Signal<[FoundStickerItem], ChatContextQueryError> in
|
||||
let scope: SearchStickersScope
|
||||
switch stickerSettings.emojiStickerSuggestionMode {
|
||||
case .none:
|
||||
scope = []
|
||||
case .all:
|
||||
scope = [.installed, .remote]
|
||||
if stickerConfiguration.disableLocalSuggestions {
|
||||
scope = [.remote]
|
||||
} else {
|
||||
scope = [.installed, .remote]
|
||||
}
|
||||
case .installed:
|
||||
scope = [.installed]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user