Video message recording improvements

This commit is contained in:
Ilya Laktyushin
2024-01-14 10:54:16 +04:00
parent 2bccbfea3b
commit 40c4378bde
7 changed files with 185 additions and 88 deletions

View File

@@ -689,6 +689,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return false
}
if strongSelf.presentRecordedVoiceMessageDiscardAlert(action: action, performAction: false) {
return false
}
return true
}
@@ -743,6 +747,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
strongSelf.openViewOnceMediaMessage(message)
return false
}
} else if file.isVideo {
if !displayVoiceMessageDiscardAlert() {
return false
}
}
}
if let invoice = media as? TelegramMediaInvoice, let extendedMedia = invoice.extendedMedia {
@@ -17359,6 +17367,25 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return false
}
func presentRecordedVoiceMessageDiscardAlert(action: @escaping () -> Void = {}, alertAction: (() -> Void)? = nil, delay: Bool = false, performAction: Bool = true) -> Bool {
if let _ = self.presentationInterfaceState.recordedMediaPreview {
alertAction?()
Queue.mainQueue().after(delay ? 0.2 : 0.0) {
self.present(textAlertController(context: self.context, updatedPresentationData: self.updatedPresentationData, title: nil, text: self.presentationData.strings.Conversation_DiscardRecordedVoiceMessageDescription, actions: [TextAlertAction(type: .genericAction, title: self.presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Conversation_DiscardRecordedVoiceMessageAction, action: { [weak self] in
self?.stopMediaRecorder()
Queue.mainQueue().after(0.1) {
action()
}
})]), in: .window(.root))
}
return true
} else if performAction {
action()
}
return false
}
func presentAutoremoveSetup() {
guard let peer = self.presentationInterfaceState.renderedPeer?.peer else {
return