Register an Activity While Offline
The registration flow must function fully without network access. Submitted registrations are stored in the local SQLite store and the local storage adapter flags them as pending sync. When the device regains connectivity, the sync service pushes pending records to Supabase. Conflicts (e.g. another device submitted the same record) are resolved server-side with last-write-wins for non-financial fields. The peer mentor sees a subtle 'Pending sync' badge on registrations awaiting upload. The sync process runs automatically in the background and clears the badge on success.
User Story
Acceptance Criteria
- Given my device is offline (airplane mode), when I complete the full registration flow and tap Confirm, then the activity is saved locally and a confirmation view is shown with a 'Saved offline — will sync when connected' message
- Given I have 3 pending offline registrations, when connectivity is restored, then all 3 are synced to Supabase within 60 seconds and the pending badges are removed
- Given a sync fails due to a server error, when the sync is retried, then it retries up to 3 times with exponential backoff before surfacing an error to the peer mentor
- Given I restart the app while offline records are pending, when the app launches, then the pending records are preserved and sync resumes once connectivity is available
- Given I am online and submit a registration, when the submission is complete, then no offline badge is shown and the record is immediately visible in my activity history
Business Value
Peer mentors often work in environments with unreliable connectivity — community centres, care facilities, rural areas. If the app requires a live connection for registration, peer mentors will revert to paper or forget to log activities entirely. Offline-first registration is a prerequisite for achieving the data completeness that Bufdir reporting depends on.
Components
- Activity Registration Cubit service
- Activity Registration Service service
- Activity Repository data
- Supabase Activity Client infrastructure
- Local Storage Adapter infrastructure
- Local Storage Adapter infrastructure