feat(pwa): Offline study logging & automatic synchronization queue

Open
#277 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
firebase, react, typescript

Research direction

Start by reading src/components/newnote/hooks/use-note-submission.ts and src/firebase.ts, then inspect the existing /api/groups/post-note flow and test setup. Define the queue in src/utils/offline-sync-queue.ts and the status UI in src/components/common/offline-banner.tsx. Done means offline notes are retained without a blocking error, sync automatically after reconnection, offline status is visible, and existing unit and E2E tests pass.

Written by the indexing model from the issue text.

Description

good first issue hacktoberfest help wanted
Problem Statement

Currently, posting a scripture note or completing daily study requires an active network connection (POST /api/groups/post-note). When users study offline (e.g., on airplanes, subways, or in areas with poor reception), submissions fail immediately with a network error toast, disrupting their study streak and workflow.

Proposed Solution

Implement an offline mutation queue (Outbox Pattern) for study notes and streak check-ins:

  1. Offline Note Queueing (IndexedDB / localStorage):
    • When offline (!navigator.onLine or API call failure due to network), save the pending note submission payload into a local queue.
    • Show a non-blocking toast: "Saved offline. Your streak and note will sync automatically once connected."
  2. Auto-sync on Reconnection:
    • Listen to window.addEventListener('online') (or Service Worker Sync if supported).
    • Drain the offline queue in chronological order, replaying the POST /api/groups/post-note requests.
  3. Offline Status UI:
    • Add a subtle offline banner or badge in the navigation/dashboard when disconnected.
  4. Firestore Offline Persistence:
    • Ensure Firestore's persistentLocalCache or IndexedDB cache is properly initialized in src/firebase.ts so users can browse previously fetched scriptures and notes while offline.
Target Files
  • src/components/newnote/hooks/use-note-submission.ts
  • src/firebase.ts
  • src/utils/offline-sync-queue.ts (New utility / store)
  • src/components/common/offline-banner.tsx (New component)
Acceptance Criteria
  • Submitting a note while offline stores the draft locally and does not show a blocking error.
  • When internet connectivity is restored, the queued note is automatically sent to /api/groups/post-note and updates the user's streak.
  • Offline status is clearly communicated in the UI.
  • Existing unit and E2E tests pass.
Dominant language
TypeScript
Stars
10
Forks
2
Avg merge
8h 42m
Merged PRs (30d)
34

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ScriptureHabit/scripture-habit

All issues in ScriptureHabit/scripture-habit

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.