setPlaybackProgress can take an attachment instead of stream

This commit is contained in:
Pete Walters 2026-03-31 09:56:33 -05:00 committed by GitHub
parent 528a5c1562
commit da14a07bc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View File

@ -209,12 +209,12 @@ public class CVAudioPlayer: NSObject {
public func setPlaybackProgress(
progress: TimeInterval,
forAttachmentStream attachmentStream: AttachmentStream,
forAttachment attachment: Attachment,
) {
AssertIsOnMainThread()
progressCache[attachmentStream.id] = progress
if let audioPlayback, audioPlayback.attachmentId == attachmentStream.id {
progressCache[attachment.id] = progress
if let audioPlayback, audioPlayback.attachmentId == attachment.id {
audioPlayback.setProgress(progress)
}
}

View File

@ -300,9 +300,6 @@ public class CVComponentAudioAttachment: CVComponentBase, CVComponent {
return
}
let location = sender.location(in: audioMessageView)
guard let attachmentStream else {
return
}
switch sender.state {
case .changed:
let progress = audioMessageView.progressForLocation(location)
@ -312,7 +309,10 @@ public class CVComponentAudioAttachment: CVComponentBase, CVComponent {
// we still call `scrubToLocation` above in order to update the slider.
audioMessageView.clearOverrideProgress(animated: false)
let scrubbedTime = audioMessageView.scrubToLocation(location)
AppEnvironment.shared.cvAudioPlayerRef.setPlaybackProgress(progress: scrubbedTime, forAttachmentStream: attachmentStream)
AppEnvironment.shared.cvAudioPlayerRef.setPlaybackProgress(
progress: scrubbedTime,
forAttachment: attachment,
)
case .possible, .began, .failed, .cancelled:
audioMessageView.clearOverrideProgress(animated: false)
@unknown default:

View File

@ -266,7 +266,7 @@ class AudioCell: MediaTileListModeCell {
let cvAudioPlayer = AppEnvironment.shared.cvAudioPlayerRef
cvAudioPlayer.setPlaybackProgress(
progress: scrubbedTime,
forAttachmentStream: audioItem.attachmentStream.attachmentStream,
forAttachment: audioItem.attachmentStream.attachment,
)
case .possible, .failed, .cancelled:
audioMessageView.clearOverrideProgress(animated: false)