Skip to content

bug: Weekly Target progress resets to totalSolved on transient API failure (#297)#328

Open
yashvi-3106 wants to merge 1 commit into
codepvg:mainfrom
yashvi-3106:bug-fix-weekly-target-reset
Open

bug: Weekly Target progress resets to totalSolved on transient API failure (#297)#328
yashvi-3106 wants to merge 1 commit into
codepvg:mainfrom
yashvi-3106:bug-fix-weekly-target-reset

Conversation

@yashvi-3106

Copy link
Copy Markdown
Contributor

Description

Fixes the issue where a user's weekly target baseline count (goal.baseCount) would get overwritten or initialized to 0 during a transient API failure (such as rate limits or network issues) on profile page load. This prevented progress from resetting correctly and immediately marked targets as completed.

Linked Issue

Fixes #297

Changes Made

  • Refactored fetchSolvedCount() to propagate fetch failures and network errors instead of defaulting to returning 0.
  • Caught errors in render() so that the baseline count is not initialized to 0 when the API fails on load. Instead, the UI displays [ FAILED TO SYNC PROGRESS ] in red.
  • Wrapped the save button handler in a try-catch block to verify the API response before saving the target to localStorage. If it fails, the input border turns red and updates the placeholder to "API Error, retry".
  • Added a focus event listener to reset the target input field's error states and restore the default placeholder.

Type of Change

  • Bug fix
  • New feature
  • UI/Visual update
  • Documentation update
  • Refactor

Testing

  • Tested locally
  • Tested on mobile viewport (if applicable)
  • No console errors introduced

Checklist

  • My code follows the project's coding style
  • I have formatted my code locally by running npx prettier --write . before submitting
  • I am submitting my PR from a dedicated feature/* branch, not the main branch
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have updated documentation if required
  • I have linked the relevant issue

Screenshots / Screen Recording

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request.

Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully.

Formatting and Branching

  • Please confirm you have formatted your code locally using npx prettier --write . before requesting a review.
  • Ensure this PR is made from a feature/* branch and not main.

Note: This project is currently maintained by a solo maintainer, so reviews and responses may sometimes take a little time. Thanks for your patience.

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.

bug: Weekly Target progress resets to totalSolved on transient API failure

1 participant