Skip to content

feat: implement auto-sync for unsubmitted offline Jap counts #5

@nitishchaubeyy

Description

@nitishchaubeyy

📝 Problem Statement

Users sometimes perform Japs but forget to hit the "Submit" button. Currently, this data stays in local storage and isn't reflected in the database or leaderboard. If the user opens the app the next day, the old count is still there, leading to confusion and potential loss of streaks.

🚀 Proposed Solution

Implement an auto-sync mechanism that pushes pending local counts to the server automatically.

Key Changes:

  • Sync Logic: On app initialization (Dashboard load), check if pending_japs exist in local storage.
  • Date Validation: If pending japs belong to a previous date, auto-submit them before starting the new day's session.
  • Background Sync (PWA): Explore Service Worker sync event to push data even if the app is minimized (Optional/Future).
  • User Feedback: Show a toast notification when auto-sync completes: "Your pending Japs from yesterday have been successfully logged!"

✅ Acceptance Criteria

  • No manual Jap count is lost if the user closes the app without submitting.
  • The system distinguishes between "Today's Japs" and "Leftover Japs" from the previous session.
  • Streaks are protected by ensuring late-night Japs are counted for the correct day.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededpwaProgressive Web app

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions