fix(music): mark only the active sleep timer preset selected

All timed presets shared one 'timed' bool, so arming any of 15/30/60
minutes checkmarked all three. The service now retains the armed
duration (sleepTimerDuration) and the menu marks the matching preset.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
edde746
2026-07-06 15:31:29 +02:00
co-authored by Claude Fable 5
parent 32c4810c21
commit 226be37f85
4 changed files with 33 additions and 1 deletions
@@ -929,6 +929,23 @@ void main() {
});
});
test('timed sleep timer exposes its armed duration for the preset menu', () async {
await h.playTracks([t1]);
h.service.setSleepTimer(const Duration(minutes: 30));
expect(h.service.sleepTimerActive, isTrue);
expect(h.service.sleepTimerDuration, const Duration(minutes: 30));
expect(h.service.sleepTimerEndOfTrack, isFalse);
h.service.setSleepTimer(null, endOfTrack: true);
expect(h.service.sleepTimerDuration, isNull);
expect(h.service.sleepTimerActive, isTrue);
h.service.setSleepTimer(null);
expect(h.service.sleepTimerActive, isFalse);
expect(h.service.sleepTimerDuration, isNull);
});
test('end-of-track sleep timer suppresses arming and pauses at completion', () async {
await h.playTracks([t1, t2]);
expect(h.player.armed?.uri, _urlFor(t2));