Auto-Save Contact Edit Draft to Prevent Data Loss
The Edit Contact Screen implements periodic auto-save of the current form state to SQLite on the device. The draft is keyed by contact ID so that returning to the edit screen for the same contact restores the last saved draft state. A subtle 'Draft saved' indicator confirms when a save has occurred. On final form submission, the local draft is deleted. If the user explicitly discards changes (via a cancel action with a confirmation dialog), the draft is also deleted. The auto-save interval is set low enough to prevent meaningful data loss (target: every 10 seconds of inactivity or on each step navigation). This is particularly important for peer mentors using the app in the field on mobile where interruptions are frequent.
User Story
Acceptance Criteria
- Given a user is editing a contact and has made changes, when 10 seconds of inactivity passes, then the form state is saved to SQLite and a 'Draft saved' indicator briefly appears
- Given a user has a draft saved and navigates back from the edit screen without submitting, when they return to the edit screen for the same contact, then their draft data is pre-populated in the form
- Given a user cancels editing and confirms discard in the confirmation dialog, when they later return to the edit screen, then no draft is restored and a blank form is shown
- Given a user submits the edit form successfully, when the save completes, then the local draft is deleted from SQLite
- Given the device runs low on storage, when auto-save is attempted, then a graceful failure is handled without crashing the app and the user is informed to save manually
Business Value
Peer mentors frequently use the app immediately after a home visit while managing other tasks — phone calls, transit, family responsibilities. Without auto-save, any interruption during a lengthy contact edit results in complete data loss, which discourages use of the edit feature and leads to information being recorded informally or not at all. Auto-save removes a significant friction point for the primary mobile field-use case and directly supports the design principle of minimum cognitive load.
Components
- Edit Contact Screen ui
- Contact Management Service service