Hanziness / FocusTide

Modern and customizable productivity timer app that runs in your browser.
https://focustide.app
MIT License
321 stars 35 forks source link

fix(ticker): Fix wrong sound playing on auto-advance #365

Closed Hanziness closed 7 months ago

Hanziness commented 7 months ago

When auto-advancing was re-implemented in #361, the app started playing the wrong sound when the section automatically advanced. This was caused by Vue handling the section advance the following way:

  1. The events store receives the TIMER_FINISH event (-> there is a watcher in the web component that plays the next section's sound based on this event)
  2. The schedule store gets the call to advance the current section
  3. The watcher plays the sound of the next section (but by this time, the schedule has already advanced, so it will play the second next section's sound)

This is fixed by wrapping the advance() call in a nextTick, so the correct sound will start playing in the current tick, and only then will the schedule advance.