mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Display voice message progress cursor if progress is greater than zero (#2077)
This commit is contained in:
parent
bc46c48b2e
commit
acd079199a
@ -41,7 +41,9 @@ class AudioPlayerState: ObservableObject, Identifiable {
|
||||
/// updates are delayed by a fixed amount of time
|
||||
@Published private(set) var playerButtonPlaybackState: AudioPlayerPlaybackState
|
||||
@Published private(set) var progress: Double
|
||||
@Published private(set) var showProgressIndicator: Bool
|
||||
var showProgressIndicator: Bool {
|
||||
progress > 0
|
||||
}
|
||||
|
||||
private weak var audioPlayer: AudioPlayerProtocol?
|
||||
private var audioPlayerSubscription: AnyCancellable?
|
||||
@ -65,7 +67,6 @@ class AudioPlayerState: ObservableObject, Identifiable {
|
||||
self.duration = duration
|
||||
self.waveform = waveform ?? EstimatedWaveform(data: [])
|
||||
self.progress = progress
|
||||
showProgressIndicator = false
|
||||
playbackState = .stopped
|
||||
playerButtonPlaybackState = .stopped
|
||||
setupPlaybackStateSubscription()
|
||||
@ -79,7 +80,6 @@ class AudioPlayerState: ObservableObject, Identifiable {
|
||||
func updateState(progress: Double) async {
|
||||
let progress = max(0.0, min(progress, 1.0))
|
||||
self.progress = progress
|
||||
showProgressIndicator = true
|
||||
if let audioPlayer {
|
||||
var shouldResumeProgressPublishing = false
|
||||
if audioPlayer.state == .playing {
|
||||
@ -108,7 +108,6 @@ class AudioPlayerState: ObservableObject, Identifiable {
|
||||
audioPlayerSubscription = nil
|
||||
audioPlayer = nil
|
||||
playbackState = .stopped
|
||||
showProgressIndicator = false
|
||||
}
|
||||
|
||||
func reportError(_ error: Error) {
|
||||
@ -143,13 +142,11 @@ class AudioPlayerState: ObservableObject, Identifiable {
|
||||
}
|
||||
startPublishProgress()
|
||||
playbackState = .playing
|
||||
showProgressIndicator = true
|
||||
case .didPausePlaying, .didStopPlaying, .didFinishPlaying:
|
||||
stopPublishProgress()
|
||||
playbackState = .stopped
|
||||
if case .didFinishPlaying = action {
|
||||
progress = 0.0
|
||||
showProgressIndicator = false
|
||||
}
|
||||
case .didFailWithError:
|
||||
stopPublishProgress()
|
||||
|
@ -285,7 +285,7 @@ class AudioPlayerStateTests: XCTestCase {
|
||||
}
|
||||
audioPlayerActionsSubject.send(.didStartPlaying)
|
||||
try await deferredPlayingState.fulfill()
|
||||
XCTAssertTrue(audioPlayerState.showProgressIndicator)
|
||||
XCTAssertFalse(audioPlayerState.showProgressIndicator)
|
||||
|
||||
let deferred = deferFulfillment(audioPlayerState.$playbackState) { action in
|
||||
switch action {
|
||||
@ -300,6 +300,6 @@ class AudioPlayerStateTests: XCTestCase {
|
||||
try await deferred.fulfill()
|
||||
XCTAssertEqual(audioPlayerState.playbackState, .error)
|
||||
XCTAssertFalse(audioPlayerState.isPublishingProgress)
|
||||
XCTAssertTrue(audioPlayerState.showProgressIndicator)
|
||||
XCTAssertFalse(audioPlayerState.showProgressIndicator)
|
||||
}
|
||||
}
|
||||
|
BIN
UnitTests/__Snapshots__/PreviewTests/test_voiceMessagePreviewComposer.1.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_voiceMessagePreviewComposer.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomPlaybackView.1.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomPlaybackView.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Bubble.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Bubble.png
(Stored with Git LFS)
Binary file not shown.
BIN
UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Plain.png
(Stored with Git LFS)
BIN
UnitTests/__Snapshots__/PreviewTests/test_voiceMessageRoomTimelineView.Plain.png
(Stored with Git LFS)
Binary file not shown.
1
changelog.d/2190.feature
Normal file
1
changelog.d/2190.feature
Normal file
@ -0,0 +1 @@
|
||||
The voice message playback position indicator is displayed during playback or pause.
|
Loading…
x
Reference in New Issue
Block a user