Fix voice notes rendering at 00:00 when playback had not begun. (#30961)

* Fix clocks rendering at 00:00 when playback had not begun.

* Add a rendering test

* Add a test

* remove only

* add another test
This commit is contained in:
Will Hunt
2025-10-07 23:03:25 +01:00
committed by GitHub
parent 25f4853d97
commit 0f530f636b
4 changed files with 102 additions and 4 deletions

View File

@@ -89,9 +89,15 @@ export class PlaybackQueue {
private onPlaybackStateChange(playback: Playback, mxEvent: MatrixEvent, newState: PlaybackState): void {
// Remember where the user got to in playback
const wasLastPlaying = this.currentPlaybackId === mxEvent.getId();
if (newState === PlaybackState.Stopped && this.clockStates.has(mxEvent.getId()!) && !wasLastPlaying) {
// noinspection JSIgnoredPromiseFromCall
playback.skipTo(this.clockStates.get(mxEvent.getId()!)!);
const currentClockState = this.clockStates.get(mxEvent.getId()!);
if (newState === PlaybackState.Stopped && currentClockState !== undefined && !wasLastPlaying) {
if (currentClockState > 0) {
// skipTo will pause playback, which causes the clock to render the current
// playback seconds. If the clock state is 0, then we can just ignore
// skipping entirely.
// noinspection JSIgnoredPromiseFromCall
playback.skipTo(currentClockState);
}
} else if (newState === PlaybackState.Stopped) {
// Remove the now-useless clock for some space savings
this.clockStates.delete(mxEvent.getId()!);