mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Opening progress for giveaway and gift link messages
This commit is contained in:
@@ -677,16 +677,18 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return true
|
||||
}
|
||||
|
||||
let controllerInteraction = ChatControllerInteraction(openMessage: { [weak self] message, mode in
|
||||
let controllerInteraction = ChatControllerInteraction(openMessage: { [weak self] message, params in
|
||||
guard let strongSelf = self, strongSelf.isNodeLoaded, let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(message.id) else {
|
||||
return false
|
||||
}
|
||||
|
||||
let mode = params.mode
|
||||
|
||||
let displayVoiceMessageDiscardAlert: () -> Bool = {
|
||||
if strongSelf.presentVoiceMessageDiscardAlert(action: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
Queue.mainQueue().after(0.1, {
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, mode)
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, params)
|
||||
})
|
||||
}
|
||||
}, performAction: false) {
|
||||
@@ -736,6 +738,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
break
|
||||
}
|
||||
} else if let _ = media as? TelegramMediaGiveaway {
|
||||
let progress = params.progress
|
||||
let presentationData = strongSelf.presentationData
|
||||
|
||||
var signal = strongSelf.context.engine.payments.premiumGiveawayInfo(peerId: message.id.peerId, messageId: message.id)
|
||||
let disposable: MetaDisposable
|
||||
if let current = strongSelf.giveawayStatusDisposable {
|
||||
@@ -745,11 +750,26 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
strongSelf.giveawayStatusDisposable = disposable
|
||||
}
|
||||
|
||||
let progressSignal = Signal<Never, NoError> { subscriber in
|
||||
return EmptyDisposable
|
||||
let progressSignal = Signal<Never, NoError> { [weak self] subscriber in
|
||||
if let progress {
|
||||
progress.set(.single(true))
|
||||
return ActionDisposable {
|
||||
Queue.mainQueue().async() {
|
||||
progress.set(.single(false))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
|
||||
self?.present(controller, in: .window(.root))
|
||||
return ActionDisposable { [weak controller] in
|
||||
Queue.mainQueue().async() {
|
||||
controller?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|> runOn(Queue.mainQueue())
|
||||
|> delay(0.15, queue: Queue.mainQueue())
|
||||
|> delay(0.25, queue: Queue.mainQueue())
|
||||
let progressDisposable = progressSignal.startStrict()
|
||||
|
||||
signal = signal
|
||||
@@ -950,7 +970,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
strongSelf.push(controller)
|
||||
return true
|
||||
case let .giftCode(slug, _, _, _, _):
|
||||
strongSelf.openResolved(result: .premiumGiftCode(slug: slug), sourceMessageId: message.id)
|
||||
strongSelf.openResolved(result: .premiumGiftCode(slug: slug), sourceMessageId: message.id, progress: params.progress)
|
||||
return true
|
||||
case let .suggestedProfilePhoto(image):
|
||||
strongSelf.chatDisplayNode.dismissInput()
|
||||
@@ -3684,7 +3704,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
if case let .visible(fraction, _) = itemNode.visibility, fraction > 0.7 {
|
||||
action(Double(timestamp))
|
||||
} else {
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, .timecode(Double(timestamp)))
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, OpenMessageParams(mode: .timecode(Double(timestamp))))
|
||||
}
|
||||
found = true
|
||||
}
|
||||
@@ -3696,7 +3716,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
messageId = sourceMessageId
|
||||
}
|
||||
if let message = strongSelf.chatDisplayNode.historyNode.messageInCurrentHistoryView(messageId) {
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, .timecode(Double(timestamp)))
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, OpenMessageParams(mode: .timecode(Double(timestamp))))
|
||||
} else {
|
||||
strongSelf.navigateToMessage(messageLocation: .id(messageId, NavigateToMessageParams(timestamp: Double(timestamp), quote: nil)), animated: true, forceInCurrentChat: true)
|
||||
}
|
||||
@@ -8077,12 +8097,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
strongSelf.scheduledScrollToMessageId = nil
|
||||
if let timecode = params.timestamp, message.id == messageId {
|
||||
Queue.mainQueue().after(0.2) {
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, .timecode(timecode))
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, OpenMessageParams(mode: .timecode(timecode)))
|
||||
}
|
||||
}
|
||||
} else if case let .message(_, _, maybeTimecode) = strongSelf.subject, let timecode = maybeTimecode, initial {
|
||||
Queue.mainQueue().after(0.2) {
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, .timecode(timecode))
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, OpenMessageParams(mode: .timecode(timecode)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12057,7 +12077,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
var completed = false
|
||||
self.chatDisplayNode.historyNode.forEachVisibleItemNode { itemNode in
|
||||
if !completed, let itemNode = itemNode as? ChatMessageItemView, let message = itemNode.item?.message, let (_, soundEnabled, _, _, _) = itemNode.playMediaWithSound(), soundEnabled {
|
||||
let _ = self.controllerInteraction?.openMessage(message, .landscape)
|
||||
let _ = self.controllerInteraction?.openMessage(message, OpenMessageParams(mode: .landscape))
|
||||
completed = true
|
||||
}
|
||||
}
|
||||
@@ -14919,7 +14939,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
if let strongSelf = self, case let .result(info, _, _) = stickerPack {
|
||||
strongSelf.present(UndoOverlayController(presentationData: strongSelf.presentationData, content: .sticker(context: strongSelf.context, file: file, loop: true, title: info.title, text: strongSelf.presentationData.strings.Stickers_PremiumPackInfoText, undoText: strongSelf.presentationData.strings.Stickers_PremiumPackView, customAction: nil), elevatedLayout: false, action: { [weak self] action in
|
||||
if let strongSelf = self, action == .undo {
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, .default)
|
||||
let _ = strongSelf.controllerInteraction?.openMessage(message, OpenMessageParams(mode: .default))
|
||||
}
|
||||
return false
|
||||
}), in: .current)
|
||||
@@ -15404,7 +15424,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self.raiseToListenActivateRecordingTimer?.invalidate()
|
||||
self.raiseToListenActivateRecordingTimer = nil
|
||||
if let messageToListen = self.firstLoadedMessageToListen() {
|
||||
let _ = self.controllerInteraction?.openMessage(messageToListen, .default)
|
||||
let _ = self.controllerInteraction?.openMessage(messageToListen, OpenMessageParams(mode: .default))
|
||||
} else {
|
||||
let timeout = (self.voicePlaylistDidEndTimestamp + 1.0) - CACurrentMediaTime()
|
||||
self.raiseToListenActivateRecordingTimer = SwiftSignalKit.Timer(timeout: max(0.0, timeout), repeat: false, completion: { [weak self] in
|
||||
@@ -16421,7 +16441,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
|
||||
if case let .id(_, params) = messageLocation, let timecode = params.timestamp {
|
||||
let _ = self.controllerInteraction?.openMessage(message, .timecode(timecode))
|
||||
let _ = self.controllerInteraction?.openMessage(message, OpenMessageParams(mode: .timecode(timecode)))
|
||||
}
|
||||
} else if case let .index(index) = messageLocation, index.id.id == 0, index.timestamp > 0, case .scheduledMessages = self.presentationInterfaceState.subject {
|
||||
self.chatDisplayNode.historyNode.scrollToMessage(from: scrollFromIndex, to: index, animated: animated, scrollPosition: scrollPosition)
|
||||
@@ -17475,7 +17495,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}))
|
||||
}
|
||||
|
||||
func openResolved(result: ResolvedUrl, sourceMessageId: MessageId?, forceExternal: Bool = false, concealed: Bool = false, commit: @escaping () -> Void = {}) {
|
||||
func openResolved(result: ResolvedUrl, sourceMessageId: MessageId?, progress: Promise<Bool>? = nil, forceExternal: Bool = false, concealed: Bool = false, commit: @escaping () -> Void = {}) {
|
||||
guard let peerId = self.chatLocation.peerId else {
|
||||
return
|
||||
}
|
||||
@@ -17485,13 +17505,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
|
||||
let dismissWebAppContollers: () -> Void = {
|
||||
// if let currentWebAppController = strongSelf.currentWebAppController {
|
||||
// strongSelf.currentWebAppController = nil
|
||||
// currentWebAppController.dismiss(animated: true, completion: nil)
|
||||
// } else if let currentWebAppController = strongSelf.currentMenuWebAppController {
|
||||
// strongSelf.currentMenuWebAppController = nil
|
||||
// currentWebAppController.dismiss(animated: true, completion: nil)
|
||||
// }
|
||||
}
|
||||
|
||||
switch navigation {
|
||||
@@ -17568,7 +17581,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
}, dismissInput: { [weak self] in
|
||||
self?.chatDisplayNode.dismissInput()
|
||||
}, contentContext: nil)
|
||||
}, contentContext: nil, progress: progress)
|
||||
}
|
||||
|
||||
func openUrl(_ url: String, concealed: Bool, forceExternal: Bool = false, skipUrlAuth: Bool = false, skipConcealedAlert: Bool = false, message: Message? = nil, allowInlineWebpageResolution: Bool = false, progress: Promise<Bool>? = nil, commit: @escaping () -> Void = {}) {
|
||||
@@ -17589,7 +17602,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
} else if content.file == nil, (content.image == nil || content.isMediaLargeByDefault == true || content.isMediaLargeByDefault == nil), let embedUrl = content.embedUrl, !embedUrl.isEmpty {
|
||||
progress?.set(.single(false))
|
||||
if let controllerInteraction = self.controllerInteraction {
|
||||
if controllerInteraction.openMessage(message, .default) {
|
||||
if controllerInteraction.openMessage(message, OpenMessageParams(mode: .default)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user