Note Draft Auto-Save Service
Component Detail
Service Layer
medium complexity
mobile
1
Dependencies
1
Dependents
0
Entities
0
Integrations
Description
Riverpod StateNotifier that listens to note body changes in the editor and persists drafts to the local Drift database using a debounce timer (typically 2-3 seconds). Ensures in-progress notes are never lost due to unexpected navigation or connectivity loss. Marks draft records with a pending-sync flag so the background sync queue picks them up when connectivity is restored.
note-draft-autosave-service
Responsibilities
- Debounce text-change events and write draft note body to local Drift DB
- Set pending-sync flag on draft records for the offline mutation outbox
- Clear draft flag and trigger backend sync on explicit save or publish
- Expose draft-exists state to the UI so unsaved indicator can be rendered
Interfaces
onBodyChanged(noteId: String, body: String) -> void
saveDraftNow(noteId: String) -> Future<void>
discardDraft(noteId: String) -> Future<void>
watchDraftState(noteId: String) -> Stream<DraftState>