mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
Improve poll retraction progress
This commit is contained in:
@@ -9996,6 +9996,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var signal = strongSelf.context.engine.messages.requestMessageSelectPollOption(messageId: id, opaqueIdentifiers: [])
|
||||||
let disposables: DisposableDict<MessageId>
|
let disposables: DisposableDict<MessageId>
|
||||||
if let current = strongSelf.selectMessagePollOptionDisposables {
|
if let current = strongSelf.selectMessagePollOptionDisposables {
|
||||||
disposables = current
|
disposables = current
|
||||||
@@ -10003,24 +10005,43 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
disposables = DisposableDict()
|
disposables = DisposableDict()
|
||||||
strongSelf.selectMessagePollOptionDisposables = disposables
|
strongSelf.selectMessagePollOptionDisposables = disposables
|
||||||
}
|
}
|
||||||
let controller = OverlayStatusController(theme: strongSelf.presentationData.theme, type: .loading(cancelled: nil))
|
|
||||||
strongSelf.present(controller, in: .window(.root))
|
var cancelImpl: (() -> Void)?
|
||||||
let signal = strongSelf.context.engine.messages.requestMessageSelectPollOption(messageId: id, opaqueIdentifiers: [])
|
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|> afterDisposed { [weak controller] in
|
let progressSignal = Signal<Never, NoError> { subscriber in
|
||||||
Queue.mainQueue().async {
|
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: {
|
||||||
|
cancelImpl?()
|
||||||
|
}))
|
||||||
|
strongSelf.present(controller, in: .window(.root), with: ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||||
|
return ActionDisposable { [weak controller] in
|
||||||
|
Queue.mainQueue().async() {
|
||||||
controller?.dismiss()
|
controller?.dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|> runOn(Queue.mainQueue())
|
||||||
|
|> delay(0.3, queue: Queue.mainQueue())
|
||||||
|
let progressDisposable = progressSignal.start()
|
||||||
|
|
||||||
|
signal = signal
|
||||||
|
|> afterDisposed {
|
||||||
|
Queue.mainQueue().async {
|
||||||
|
progressDisposable.dispose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cancelImpl = {
|
||||||
|
disposables.set(nil, forKey: id)
|
||||||
|
}
|
||||||
|
|
||||||
disposables.set((signal
|
disposables.set((signal
|
||||||
|> deliverOnMainQueue).start(error: { _ in
|
|> deliverOnMainQueue).start(completed: { [weak self] in
|
||||||
guard let _ = self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}, completed: {
|
if self.selectPollOptionFeedback == nil {
|
||||||
if strongSelf.selectPollOptionFeedback == nil {
|
self.selectPollOptionFeedback = HapticFeedback()
|
||||||
strongSelf.selectPollOptionFeedback = HapticFeedback()
|
|
||||||
}
|
}
|
||||||
strongSelf.selectPollOptionFeedback?.success()
|
self.selectPollOptionFeedback?.success()
|
||||||
}), forKey: id)
|
}), forKey: id)
|
||||||
}, requestStopPollInMessage: { [weak self] id in
|
}, requestStopPollInMessage: { [weak self] id in
|
||||||
guard let strongSelf = self, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(id) else {
|
guard let strongSelf = self, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(id) else {
|
||||||
|
|||||||
Reference in New Issue
Block a user