Skip to content

Fix/log time on click - #189

Merged
dannyvfilms merged 1 commit into
dannyvfilms:latestfrom
nakenyon:fix/log-time-on-click
May 4, 2026
Merged

Fix/log time on click#189
dannyvfilms merged 1 commit into
dannyvfilms:latestfrom
nakenyon:fix/log-time-on-click

Conversation

@nakenyon

@nakenyon nakenyon commented May 4, 2026

Copy link
Copy Markdown

Fix: Use current time when logging plays, not page load time

Summary

When logging a new play, the datetime field was pre-filled with the time the page was loaded rather than the time the user actually interacted with the form. This affected two separate code paths:

  • Main track modal (mediaStatusDateHandler.js): The current time was captured once into a const now variable during Alpine.js component initialisation and reused for all subsequent writes — including inside the status-change event listener, which could fire minutes after the page loaded.
  • Episode track modal (fill_track_episode.html,fill_track_song.html ): The watch date was set server-side using Django's {% now %} template tag, baking the page-render time into the HTML before the user had even opened the modal.

Changes

  • src/static/js/mediaStatusDateHandler.js: Removed the upfront const now = getCurrentDateTime() call and replaced each usage with a fresh getCurrentDateTime() call at the moment the field value is actually written.
  • src/templates/app/components/fill_track_episode.html and src/templates/app/components/fill_track_song.html: Replaced the server-rendered {% now %} default with an Alpine x-effect that recomputes the current time (with timezone adjustment) each time the modal is opened. fill_track_song.html is shared between music album and podcast episode tracking.

Testing

  1. Open a show's season page and wait a minute or two before clicking to log an episode — the watch date should reflect the time you clicked, not the page load time.
  2. On a media detail page, open the track modal, wait, then change the status to Completed or In Progress — the auto-filled date should match the time you changed the status.

@nakenyon
nakenyon marked this pull request as draft May 4, 2026 21:58
@nakenyon
nakenyon force-pushed the fix/log-time-on-click branch from e5f196d to ac01904 Compare May 4, 2026 21:59
@nakenyon
nakenyon marked this pull request as ready for review May 4, 2026 21:59
The datetime auto-fill for new play records was capturing the time once
at component initialisation and reusing that stale value. For the main
track modal (mediaStatusDateHandler.js) this meant the status-change
handler always inserted the page-load time rather than the time the user
actually changed the status. For the episode track modal
(fill_track_episode.html) the time was baked in server-side via Django's
{% now %} tag, so it was frozen at page render.

Fix: call getCurrentDateTime() at the moment each field is written
(mediaStatusDateHandler.js), and replace the server-rendered default with
an Alpine x-effect that recomputes the current time whenever the episode
modal opens (fill_track_episode.html).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nakenyon
nakenyon force-pushed the fix/log-time-on-click branch from ac01904 to 9f05f8d Compare May 4, 2026 22:31
@dannyvfilms
dannyvfilms merged commit 3fc13b5 into dannyvfilms:latest May 4, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants