Fix voice message resetting bug

This commit is contained in:
Niels Andriesse 2021-02-22 14:23:15 +11:00
parent 5846de634d
commit b2c6a5229b
1 changed files with 4 additions and 1 deletions

View File

@ -136,6 +136,7 @@ public final class VoiceMessageView : UIView {
private func handleIsPlayingChanged() {
toggleImageView.image = isPlaying ? UIImage(named: "Pause") : UIImage(named: "Play")
if !isPlaying { progress = 0 }
}
private func handleProgressChanged() {
@ -144,7 +145,9 @@ public final class VoiceMessageView : UIView {
if isDownloaded { loader.stopAnimating() } else if !loader.isAnimating { loader.startAnimating() }
guard isDownloaded else { return }
countdownLabel.text = OWSFormat.formatDurationSeconds(duration - progress)
guard viewItem.audioProgressSeconds > 0 && viewItem.audioDurationSeconds > 0 else { return }
guard viewItem.audioProgressSeconds > 0 && viewItem.audioDurationSeconds > 0 else {
return progressViewRightConstraint.constant = -VoiceMessageView.width
}
let fraction = viewItem.audioProgressSeconds / viewItem.audioDurationSeconds
progressViewRightConstraint.constant = -(VoiceMessageView.width * (1 - fraction))
}