Repository navigation
Ansh - 🔥 timer submission pause and clear behavior - #5778
AnshShah-18 wants to merge 2 commits into
Conversation
✅ Deploy Preview for highestgoodnetwork-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
vidiyala99
left a comment
There was a problem hiding this comment.
Tested at fb4ba62 on a local build of this branch, with the backend on HGNRest development running locally (apidev returns 500 tonight). Logged in as a volunteer and drove the real timer over its websocket. The test account has no projects, so I injected one fake project into the form and answered the time-entry save from the browser instead of sending it. Nothing was written to the dev DB.
Works:
- The timer pauses as soon as Submit is clicked. I held the save for 6 seconds. The timer stayed at 00:26:41 the whole time, where on
developmentit would keep counting down. - After the save succeeds, the timer clears. It went back to the full goal (00:31:00), the form closed, and "Time logged successfully!" showed.
- All 19 tests in
src/components/TimerandTimeEntryForm.test.jsxpass locally, including the new pause-before-clear test.
Approving. Two notes for you and Jae:
- If the save returns a server error, the timer is still cleared and the time is lost. I answered the save with a 500: the app showed "Time logged successfully!", cleared the timer to 00:31:00, and closed the form. This isn't new.
postTimeEntrycatches the error and returns the status code instead of throwing, sosubmitTimeEntrynever reacheshandleError, anddevelopmentdoes the same thing with STOP_TIMER. Now that this PR clears the timer, it's worth a small follow-up: check the returned status before callingsendClear(), and if the save failed, leave the timer paused so the user can retry. - This PR and #5788 (Mahika) fix the same bug in different ways, and
git merge-treeshows they conflict inTimeEntryForm.jsxandTimer.jsx. Only one of them should merge. This one is smaller and needs no backend change. It also merges cleanly with #5751.
Not blocking: replacing STOP_TIMER with CLEAR_TIMER drops the old "keep the leftover time after a partial log" behaviour (stopTimer set goal = time left). That's what the description asks for, so I'm only flagging it in case anyone relied on it.
|



Description
Fixes a timer issue where submitting a time log from the timer could take several seconds to process while the timer continued running. After the submission completed, the timer could also remain at the leftover time instead of clearing/resetting.
The issue was caused by the time-entry flow waiting for the time-log request to finish before stopping the timer. The previous
STOP_TIMERbehavior also preserved the remaining timer value.This PR updates the flow so the timer pauses immediately when the user submits a timer-based time log, then clears/reset the timer only after the time entry has been successfully saved.
Related PRS (if any):
None. This is a frontend-only change and does not require a backend PR.
Main changes explained:
TimeEntryForm.jsxto pause the timer immediately after form validation and before the time-log submission request begins.CLEAR_TIMERinstead ofSTOP_TIMER, ensuring the timer resets after the time log is successfully saved.Timer.jsxto passsendPauseandsendClearto the timer time-entry form.How to test:
Check out this PR branch:
Start the frontend:
Start the development backend.
Log in to the development site with a test account that has a project/task available for time logging.
Start the timer and allow some time to accumulate.
Click Log Time.
Select a valid project/task, enter the required notes, and click Submit.
Verify that the timer pauses immediately when Submit is clicked instead of continuing to count down while the time-log request is processing.
After the time log is successfully submitted, verify that:
00:15:00.00:00:00.Run the related automated tests:
Expected result: 19 tests passed across 3 test files.
Screenshots or videos of changes:
Untitled.mp4