From 6df5f7268b79e09481358bd4a7daeb63891cb362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A9v=C3=A9nyi=20Benedek?= Date: Mon, 2 Dec 2024 17:43:39 +0100 Subject: [PATCH] Looks like we were doing some unnecessary work --- cozy/view_model/sleep_timer_view_model.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cozy/view_model/sleep_timer_view_model.py b/cozy/view_model/sleep_timer_view_model.py index e5e51ec1..0be09ca0 100644 --- a/cozy/view_model/sleep_timer_view_model.py +++ b/cozy/view_model/sleep_timer_view_model.py @@ -53,8 +53,6 @@ def remaining_seconds(self, new_value: int): else: self._stop_timer() - self._notify("timer_enabled") - @property def system_power_control(self) -> SystemPowerControl: return self._system_power_control @@ -72,9 +70,8 @@ def stop_after_chapter(self, new_value: bool): self._player.play_next_chapter = not new_value if new_value: - self._stop_timer() self.remaining_seconds = 0 - log.info("Sleep Timer Stop at end of Chapter Set") + log.info("Stop at end of Chapter Set") self._notify("remaining_seconds") self._notify("stop_after_chapter") @@ -98,6 +95,7 @@ def _start_timer(self): self._timer_running = True log.info("Start Sleep Timer") + self._notify("timer_enabled") def _stop_timer(self): self._timer_running = False @@ -122,8 +120,7 @@ def _on_timer_tick(self): def _on_player_changed(self, event, _): if event == "position": - if self._timer_running and self._player._play_next_chapter: - # Protected attribute access above, because I don't feel like going through two layers of properties + if self._timer_running: self._on_timer_tick() elif event == "chapter-changed": self.stop_after_chapter = False