Skip to content

Commit 753fb3b

Browse files
committed
feat: optimize sleep timer state management in NowPlayingPage
1 parent dc9d884 commit 753fb3b

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

lib/screens/now_playing_page.dart

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,6 @@ class NowPlayingPage extends StatelessWidget {
551551
if (hours > 0) {
552552
setState(() {
553553
hours--;
554-
sleepTimerNotifier.value = Duration(
555-
hours: hours,
556-
minutes: minutes,
557-
);
558554
});
559555
}
560556
},
@@ -565,10 +561,6 @@ class NowPlayingPage extends StatelessWidget {
565561
onPressed: () {
566562
setState(() {
567563
hours++;
568-
sleepTimerNotifier.value = Duration(
569-
hours: hours,
570-
minutes: minutes,
571-
);
572564
});
573565
},
574566
),
@@ -589,10 +581,6 @@ class NowPlayingPage extends StatelessWidget {
589581
if (minutes > 0) {
590582
setState(() {
591583
minutes--;
592-
sleepTimerNotifier.value = Duration(
593-
hours: hours,
594-
minutes: minutes,
595-
);
596584
});
597585
}
598586
},
@@ -603,10 +591,6 @@ class NowPlayingPage extends StatelessWidget {
603591
onPressed: () {
604592
setState(() {
605593
minutes++;
606-
sleepTimerNotifier.value = Duration(
607-
hours: hours,
608-
minutes: minutes,
609-
);
610594
});
611595
},
612596
),
@@ -626,6 +610,10 @@ class NowPlayingPage extends StatelessWidget {
626610
final duration = Duration(hours: hours, minutes: minutes);
627611
if (duration.inSeconds > 0) {
628612
audioHandler.setSleepTimer(duration);
613+
sleepTimerNotifier.value = Duration(
614+
hours: hours,
615+
minutes: minutes,
616+
);
629617
showToast(context, context.l10n!.addedSuccess);
630618
}
631619
Navigator.pop(context);

0 commit comments

Comments
 (0)