diff --git a/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift b/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift index 80d446da8d..bddf128ca9 100644 --- a/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift +++ b/submodules/SettingsUI/Sources/Themes/CustomWallpaperPicker.swift @@ -310,7 +310,7 @@ public func uploadCustomPeerWallpaper(context: AccountContext, wallpaper: Wallpa context.account.pendingPeerMediaUploadManager.add(peerId: peerId, content: .wallpaper(temporaryWallpaper)) - Queue.mainQueue().async { + Queue.mainQueue().after(0.05) { completion() } } diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift index f30c149eeb..202a157a15 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift @@ -508,7 +508,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { Queue.mainQueue().after(0.1) { self.brightnessNode.isHidden = false - self.temporaryImageNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, delay: 0.2, removeOnCompletion: false, completion: { [weak self] _ in + self.temporaryImageNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, delay: 0.2, removeOnCompletion: false, completion: { [weak self] _ in self?.temporaryImageNode.image = nil self?.temporaryImageNode.layer.removeAllAnimations() }) diff --git a/submodules/TelegramCore/Sources/PendingMessages/PendingPeerMediaUploadManager.swift b/submodules/TelegramCore/Sources/PendingMessages/PendingPeerMediaUploadManager.swift index a1938e5310..626a016847 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/PendingPeerMediaUploadManager.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/PendingPeerMediaUploadManager.swift @@ -147,6 +147,8 @@ private final class PendingPeerMediaUploadManagerImpl { let stateManager: AccountStateManager let accountPeerId: EnginePeer.Id + let sentMessageEventPipe: ValuePipe + private var uploadingPeerMediaValue: [EnginePeer.Id: PeerMediaUploadingItem] = [:] { didSet { if self.uploadingPeerMediaValue != oldValue { @@ -168,6 +170,8 @@ private final class PendingPeerMediaUploadManagerImpl { self.stateManager = stateManager self.accountPeerId = accountPeerId + self.sentMessageEventPipe = ValuePipe() + self.uploadingPeerMediaPromise.set(.single(self.uploadingPeerMediaValue)) } @@ -221,6 +225,8 @@ private final class PendingPeerMediaUploadManagerImpl { context.value = context.value.withMessageId(messageId) strongSelf.updateValues() + strongSelf.sentMessageEventPipe.putNext(peerId) + context.disposable.set((uploadPeerMedia(postbox: postbox, network: network, stateManager: stateManager, peerId: peerId, content: content) |> deliverOn(queue)).start(next: { [weak self, weak context] value in guard let strongSelf = self, let initialContext = context else { @@ -324,6 +330,17 @@ private final class PendingPeerMediaUploadManagerImpl { } |> distinctUntilChanged } + + public func sentMessageEvents(peerId: EnginePeer.Id) -> Signal { + return self.sentMessageEventPipe.signal() + |> mapToSignal { eventPeerId -> Signal in + if eventPeerId == peerId { + return .single(Void()) + } else { + return .complete() + } + } + } } public final class PendingPeerMediaUploadManager { @@ -372,4 +389,16 @@ public final class PendingPeerMediaUploadManager { return disposable } } + + public func sentMessageEvents(peerId: EnginePeer.Id) -> Signal { + return Signal { subscriber in + let disposable = MetaDisposable() + self.impl.with { impl in + disposable.set(impl.sentMessageEvents(peerId: peerId).start(next: { value in + subscriber.putNext(value) + })) + } + return disposable + } + } } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 3733d0799d..dc0b4d56cc 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -289,6 +289,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G private let controllerNavigationDisposable = MetaDisposable() private let sentMessageEventsDisposable = MetaDisposable() private let failedMessageEventsDisposable = MetaDisposable() + private let sentPeerMediaMessageEventsDisposable = MetaDisposable() private weak var currentFailedMessagesAlertController: ViewController? private let messageActionCallbackDisposable = MetaDisposable() private let messageActionUrlAuthDisposable = MetaDisposable() @@ -6147,6 +6148,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G self.controllerNavigationDisposable.dispose() self.sentMessageEventsDisposable.dispose() self.failedMessageEventsDisposable.dispose() + self.sentPeerMediaMessageEventsDisposable.dispose() self.messageActionCallbackDisposable.dispose() self.messageActionUrlAuthDisposable.dispose() self.editMessageDisposable.dispose() @@ -10758,6 +10760,15 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.present(controller, in: .window(.root)) } })) + + self.sentPeerMediaMessageEventsDisposable.set( + (self.context.account.pendingPeerMediaUploadManager.sentMessageEvents(peerId: peerId) + |> deliverOnMainQueue).start(next: { [weak self] _ in + if let self { + self.chatDisplayNode.historyNode.scrollToEndOfHistory() + } + }) + ) } }