@@ -494,7 +494,7 @@ extension ChatControllerImpl {
494494 } )
495495 } else {
496496 let proceed = {
497- self . withAudioRecorder ( { audioRecorder in
497+ self . withAudioRecorder ( resuming : true , { audioRecorder in
498498 audioRecorder. resume ( )
499499
500500 self . updateChatPresentationInterfaceState ( animated: true , interactive: true , {
@@ -617,13 +617,43 @@ extension ChatControllerImpl {
617617 self . present ( tooltipController, in: . window( . root) )
618618 }
619619
620- private func withAudioRecorder( _ f: ( ManagedAudioRecorder ) -> Void ) {
620+ private func withAudioRecorder( resuming : Bool , _ f: ( ManagedAudioRecorder ) -> Void ) {
621621 if let audioRecorder = self . audioRecorderValue {
622622 f ( audioRecorder)
623623 } else if let recordedMediaPreview = self . presentationInterfaceState. interfaceState. mediaDraftState, case let . audio( audio) = recordedMediaPreview {
624624 self . requestAudioRecorder ( beginWithTone: false , existingDraft: audio)
625625 if let audioRecorder = self . audioRecorderValue {
626626 f ( audioRecorder)
627+
628+ if !resuming {
629+ self . recorderDataDisposable. set (
630+ ( audioRecorder. takenRecordedData ( )
631+ |> deliverOnMainQueue) . startStrict (
632+ next: { [ weak self] data in
633+ if let strongSelf = self , let data = data {
634+ let audioWaveform = audio. waveform
635+
636+ strongSelf. updateChatPresentationInterfaceState ( animated: true , interactive: true , {
637+ $0. updatedInterfaceState {
638+ $0. withUpdatedMediaDraftState ( . audio(
639+ ChatInterfaceMediaDraftState . Audio (
640+ resource: audio. resource,
641+ fileSize: Int32 ( data. compressedData. count) ,
642+ duration: data. duration,
643+ waveform: audioWaveform,
644+ trimRange: data. trimRange,
645+ resumeData: data. resumeData
646+ )
647+ ) )
648+ } . updatedInputTextPanelState { panelState in
649+ return panelState. withUpdatedMediaRecordingState ( nil )
650+ }
651+ } )
652+ strongSelf. updateDownButtonVisibility ( )
653+ }
654+ } )
655+ )
656+ }
627657 }
628658 }
629659 }
@@ -632,7 +662,7 @@ extension ChatControllerImpl {
632662 if let videoRecorder = self . videoRecorderValue {
633663 videoRecorder. updateTrimRange ( start: start, end: end, updatedEnd: updatedEnd, apply: apply)
634664 } else {
635- self . withAudioRecorder ( { audioRecorder in
665+ self . withAudioRecorder ( resuming : false , { audioRecorder in
636666 audioRecorder. updateTrimRange ( start: start, end: end, updatedEnd: updatedEnd, apply: apply)
637667 } )
638668 }
0 commit comments