Skip to content

Commit 0077a07

Browse files
committed
Various fixes
1 parent 34cef80 commit 0077a07

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

submodules/TelegramUI/Sources/Chat/ChatControllerMediaRecording.swift

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

submodules/TelegramUI/Sources/ChatRecordingPreviewInputPanelNode.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ final class PlayButtonNode: ASDisplayNode {
119119

120120
transition.updateFrame(node: self.backgroundNode, frame: buttonSize.centered(in: CGRect(origin: .zero, size: size)))
121121

122-
self.playPauseIconNode.frame = CGRect(origin: CGPoint(x: 4.0, y: 1.0 - UIScreenPixel), size: CGSize(width: 21.0, height: 21.0))
122+
self.playPauseIconNode.frame = CGRect(origin: CGPoint(x: 3.0, y: 1.0 - UIScreenPixel), size: CGSize(width: 21.0, height: 21.0))
123123

124124
transition.updateFrame(node: self.durationLabel, frame: CGRect(origin: CGPoint(x: 18.0, y: 3.0), size: CGSize(width: 35.0, height: 20.0)))
125125
transition.updateAlpha(node: self.durationLabel, alpha: buttonSize.width > 27.0 ? 1.0 : 0.0)
@@ -509,7 +509,7 @@ final class ChatRecordingPreviewInputPanelNode: ChatInputPanelNode {
509509
}))
510510
}
511511

512-
let minDuration = max(2.0, 56.0 * audio.duration / waveformBackgroundFrame.size.width)
512+
let minDuration = max(1.0, 56.0 * audio.duration / waveformBackgroundFrame.size.width)
513513
let (leftHandleFrame, rightHandleFrame) = self.trimView.update(
514514
style: .voiceMessage,
515515
theme: interfaceState.theme,

0 commit comments

Comments
 (0)