Various fixes

This commit is contained in:
Ilya Laktyushin 2025-05-28 17:24:15 +02:00
parent 34cef80179
commit 0077a070f2
2 changed files with 35 additions and 5 deletions

View File

@ -494,7 +494,7 @@ extension ChatControllerImpl {
})
} else {
let proceed = {
self.withAudioRecorder({ audioRecorder in
self.withAudioRecorder(resuming: true, { audioRecorder in
audioRecorder.resume()
self.updateChatPresentationInterfaceState(animated: true, interactive: true, {
@ -617,13 +617,43 @@ extension ChatControllerImpl {
self.present(tooltipController, in: .window(.root))
}
private func withAudioRecorder(_ f: (ManagedAudioRecorder) -> Void) {
private func withAudioRecorder(resuming: Bool, _ f: (ManagedAudioRecorder) -> Void) {
if let audioRecorder = self.audioRecorderValue {
f(audioRecorder)
} else if let recordedMediaPreview = self.presentationInterfaceState.interfaceState.mediaDraftState, case let .audio(audio) = recordedMediaPreview {
self.requestAudioRecorder(beginWithTone: false, existingDraft: audio)
if let audioRecorder = self.audioRecorderValue {
f(audioRecorder)
if !resuming {
self.recorderDataDisposable.set(
(audioRecorder.takenRecordedData()
|> deliverOnMainQueue).startStrict(
next: { [weak self] data in
if let strongSelf = self, let data = data {
let audioWaveform = audio.waveform
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, {
$0.updatedInterfaceState {
$0.withUpdatedMediaDraftState(.audio(
ChatInterfaceMediaDraftState.Audio(
resource: audio.resource,
fileSize: Int32(data.compressedData.count),
duration: data.duration,
waveform: audioWaveform,
trimRange: data.trimRange,
resumeData: data.resumeData
)
))
}.updatedInputTextPanelState { panelState in
return panelState.withUpdatedMediaRecordingState(nil)
}
})
strongSelf.updateDownButtonVisibility()
}
})
)
}
}
}
}
@ -632,7 +662,7 @@ extension ChatControllerImpl {
if let videoRecorder = self.videoRecorderValue {
videoRecorder.updateTrimRange(start: start, end: end, updatedEnd: updatedEnd, apply: apply)
} else {
self.withAudioRecorder({ audioRecorder in
self.withAudioRecorder(resuming: false, { audioRecorder in
audioRecorder.updateTrimRange(start: start, end: end, updatedEnd: updatedEnd, apply: apply)
})
}

View File

@ -119,7 +119,7 @@ final class PlayButtonNode: ASDisplayNode {
transition.updateFrame(node: self.backgroundNode, frame: buttonSize.centered(in: CGRect(origin: .zero, size: size)))
self.playPauseIconNode.frame = CGRect(origin: CGPoint(x: 4.0, y: 1.0 - UIScreenPixel), size: CGSize(width: 21.0, height: 21.0))
self.playPauseIconNode.frame = CGRect(origin: CGPoint(x: 3.0, y: 1.0 - UIScreenPixel), size: CGSize(width: 21.0, height: 21.0))
transition.updateFrame(node: self.durationLabel, frame: CGRect(origin: CGPoint(x: 18.0, y: 3.0), size: CGSize(width: 35.0, height: 20.0)))
transition.updateAlpha(node: self.durationLabel, alpha: buttonSize.width > 27.0 ? 1.0 : 0.0)
@ -509,7 +509,7 @@ final class ChatRecordingPreviewInputPanelNode: ChatInputPanelNode {
}))
}
let minDuration = max(2.0, 56.0 * audio.duration / waveformBackgroundFrame.size.width)
let minDuration = max(1.0, 56.0 * audio.duration / waveformBackgroundFrame.size.width)
let (leftHandleFrame, rightHandleFrame) = self.trimView.update(
style: .voiceMessage,
theme: interfaceState.theme,