mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit '43947a3dd3035df157ee9f392252c1a9dee8b33a' into beta
This commit is contained in:
commit
fa9274938c
@ -10,6 +10,7 @@ import TelegramUIPreferences
|
||||
import AccountContext
|
||||
import TelegramStringFormatting
|
||||
import UIKitRuntimeUtils
|
||||
import MediaResources
|
||||
|
||||
public enum AttachmentButtonType: Equatable {
|
||||
case gallery
|
||||
@ -912,4 +913,39 @@ public class AttachmentController: ViewController {
|
||||
self.prepareForDismiss = prepareForDismiss
|
||||
}
|
||||
}
|
||||
|
||||
public static func preloadAttachBotIcons(context: AccountContext) -> DisposableSet {
|
||||
let disposableSet = DisposableSet()
|
||||
let _ = (context.engine.messages.attachMenuBots()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { bots in
|
||||
for bot in bots {
|
||||
for (name, file) in bot.icons {
|
||||
if [.iOSAnimated, .placeholder].contains(name), let peer = PeerReference(bot.peer) {
|
||||
if case .placeholder = name {
|
||||
let path = context.account.postbox.mediaBox.cachedRepresentationCompletePath(file.resource.id, representation: CachedPreparedSvgRepresentation())
|
||||
if !FileManager.default.fileExists(atPath: path) {
|
||||
let accountFullSizeData = Signal<(Data?, Bool), NoError> { subscriber in
|
||||
let accountResource = context.account.postbox.mediaBox.cachedResourceRepresentation(file.resource, representation: CachedPreparedSvgRepresentation(), complete: false, fetch: true)
|
||||
|
||||
let fetchedFullSize = fetchedMediaResource(mediaBox: context.account.postbox.mediaBox, reference: .media(media: .attachBot(peer: peer, media: file), resource: file.resource))
|
||||
let fetchedFullSizeDisposable = fetchedFullSize.start()
|
||||
let fullSizeDisposable = accountResource.start()
|
||||
|
||||
return ActionDisposable {
|
||||
fetchedFullSizeDisposable.dispose()
|
||||
fullSizeDisposable.dispose()
|
||||
}
|
||||
}
|
||||
disposableSet.add(accountFullSizeData.start())
|
||||
}
|
||||
} else {
|
||||
disposableSet.add(freeMediaFileInteractiveFetched(account: context.account, fileReference: .attachBot(peer: peer, media: file)).start())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
return disposableSet
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
private var bankCardDisposable: MetaDisposable?
|
||||
private var hasActiveGroupCallDisposable: Disposable?
|
||||
private var sendAsPeersDisposable: Disposable?
|
||||
private let preloadAttachBotIconsDisposables = DisposableSet()
|
||||
private var preloadAttachBotIconsDisposables: DisposableSet?
|
||||
|
||||
private let editingMessage = ValuePromise<Float?>(nil, ignoreRepeated: true)
|
||||
private let startingBot = ValuePromise<Bool>(false, ignoreRepeated: true)
|
||||
@ -4832,7 +4832,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self.nextChannelToReadDisposable?.dispose()
|
||||
self.inviteRequestsDisposable.dispose()
|
||||
self.sendAsPeersDisposable?.dispose()
|
||||
self.preloadAttachBotIconsDisposables.dispose()
|
||||
self.preloadAttachBotIconsDisposables?.dispose()
|
||||
}
|
||||
|
||||
public func updatePresentationMode(_ mode: ChatControllerPresentationMode) {
|
||||
@ -9063,7 +9063,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
}
|
||||
|
||||
self.preloadAttachBotIcons()
|
||||
self.preloadAttachBotIconsDisposables = AttachmentController.preloadAttachBotIcons(context: self.context)
|
||||
}
|
||||
|
||||
if let _ = self.focusOnSearchAfterAppearance {
|
||||
@ -15722,23 +15722,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func preloadAttachBotIcons() {
|
||||
let _ = (self.context.engine.messages.attachMenuBots()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] bots in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
for bot in bots {
|
||||
for (name, file) in bot.icons {
|
||||
if [.iOSAnimated].contains(name), let peer = PeerReference(bot.peer) {
|
||||
strongSelf.preloadAttachBotIconsDisposables.add(freeMediaFileInteractiveFetched(account: strongSelf.context.account, fileReference: .attachBot(peer: peer, media: file)).start())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private final class ContextControllerContentSourceImpl: ContextControllerContentSource {
|
||||
|
Loading…
x
Reference in New Issue
Block a user