Skip to content

Commit

Permalink
Looks like we were doing some unnecessary work
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Dec 2, 2024
1 parent d70b651 commit 6df5f72
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cozy/view_model/sleep_timer_view_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6df5f72

Please sign in to comment.