Fix sending voice messages without sound

This commit is contained in:
Ali 2020-10-19 00:55:26 +04:00
parent abcef0ff0e
commit a4a40a0aa3
5 changed files with 19 additions and 10 deletions

View File

@ -746,7 +746,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
}
}, sendCurrentMessage: { [weak self] silentPosting in
if let strongSelf = self {
strongSelf.chatDisplayNode.sendCurrentMessage(silentPosting: silentPosting)
if let _ = strongSelf.presentationInterfaceState.recordedMediaPreview {
strongSelf.sendMediaRecording(silently: silentPosting)
} else {
strongSelf.chatDisplayNode.sendCurrentMessage(silentPosting: silentPosting)
}
}
}, sendMessage: { [weak self] text in
guard let strongSelf = self, canSendMessagesToChat(strongSelf.presentationInterfaceState) else {
@ -4646,8 +4650,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
strongSelf.lockMediaRecorder()
}, deleteRecordedMedia: { [weak self] in
self?.deleteMediaRecording()
}, sendRecordedMedia: { [weak self] in
self?.sendMediaRecording()
}, sendRecordedMedia: { [weak self] silently in
self?.sendMediaRecording(silently: silently)
}, displayRestrictedInfo: { [weak self] subject, displayType in
guard let strongSelf = self else {
return
@ -8278,7 +8282,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
})
}
private func sendMediaRecording() {
private func sendMediaRecording(silently: Bool) {
self.chatDisplayNode.updateRecordedMediaDeleted(false)
if let recordedMediaPreview = self.presentationInterfaceState.recordedMediaPreview {
if let _ = self.presentationInterfaceState.slowmodeState, !self.presentationInterfaceState.isScheduledMessages {
@ -8298,7 +8302,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
}
})
self.sendMessages([.message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: arc4random64()), partialReference: nil, resource: recordedMediaPreview.resource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: Int(recordedMediaPreview.fileSize), attributes: [.Audio(isVoice: true, duration: Int(recordedMediaPreview.duration), title: nil, performer: nil, waveform: waveformBuffer)])), replyToMessageId: self.presentationInterfaceState.interfaceState.replyMessageId, localGroupingKey: nil)])
var attributes: [MessageAttribute] = []
if silently {
attributes.append(NotificationInfoMessageAttribute(flags: .muted))
}
self.sendMessages([.message(text: "", attributes: attributes, mediaReference: .standalone(media: TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: arc4random64()), partialReference: nil, resource: recordedMediaPreview.resource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: Int(recordedMediaPreview.fileSize), attributes: [.Audio(isVoice: true, duration: Int(recordedMediaPreview.duration), title: nil, performer: nil, waveform: waveformBuffer)])), replyToMessageId: self.presentationInterfaceState.interfaceState.replyMessageId, localGroupingKey: nil)])
}
}

View File

@ -87,7 +87,7 @@ final class ChatPanelInterfaceInteraction {
let stopMediaRecording: () -> Void
let lockMediaRecording: () -> Void
let deleteRecordedMedia: () -> Void
let sendRecordedMedia: () -> Void
let sendRecordedMedia: (Bool) -> Void
let displayRestrictedInfo: (ChatPanelRestrictionInfoSubject, ChatPanelRestrictionInfoDisplayType) -> Void
let displayVideoUnmuteTip: (CGPoint?) -> Void
let switchMediaRecordingMode: () -> Void
@ -163,7 +163,7 @@ final class ChatPanelInterfaceInteraction {
stopMediaRecording: @escaping () -> Void,
lockMediaRecording: @escaping () -> Void,
deleteRecordedMedia: @escaping () -> Void,
sendRecordedMedia: @escaping () -> Void,
sendRecordedMedia: @escaping (Bool) -> Void,
displayRestrictedInfo: @escaping (ChatPanelRestrictionInfoSubject, ChatPanelRestrictionInfoDisplayType) -> Void,
displayVideoUnmuteTip: @escaping (CGPoint?) -> Void,
switchMediaRecordingMode: @escaping () -> Void,

View File

@ -91,7 +91,7 @@ final class ChatRecentActionsController: TelegramBaseController {
}, stopMediaRecording: {
}, lockMediaRecording: {
}, deleteRecordedMedia: {
}, sendRecordedMedia: {
}, sendRecordedMedia: { _ in
}, displayRestrictedInfo: { _, _ in
}, displayVideoUnmuteTip: { _ in
}, switchMediaRecordingMode: {

View File

@ -291,7 +291,7 @@ final class ChatRecordingPreviewInputPanelNode: ChatInputPanelNode {
}
@objc func sendPressed() {
self.interfaceInteraction?.sendRecordedMedia()
self.interfaceInteraction?.sendRecordedMedia(false)
}
@objc func waveformPressed() {

View File

@ -397,7 +397,7 @@ final class PeerInfoSelectionPanelNode: ASDisplayNode {
}, stopMediaRecording: {
}, lockMediaRecording: {
}, deleteRecordedMedia: {
}, sendRecordedMedia: {
}, sendRecordedMedia: { _ in
}, displayRestrictedInfo: { _, _ in
}, displayVideoUnmuteTip: { _ in
}, switchMediaRecordingMode: {