ContactBloc
Component Detail
Description
BLoC service that manages all business logic and state for the contact detail and edit flows, coordinating between the local Drift database and the REST API sync queue. It applies optimistic updates immediately to local state, enqueues outbound sync operations, and performs automatic rollback on confirmed sync failures. Exposes a single reactive state stream consumed by both ContactDetailScreen and EditContactScreen.
contact-bloc
Sources & reasoning
Line 292 explicitly names contact detail and edit as core mobile screens in the MVP architecture section. Line 304 details the optimistic mutation pattern specifically required for contact edits. Both sit in the Mobile App Architecture block describing the MVP scope. The Phase 1 roadmap (line 321) lists contact list and overview as MVP deliverables, making detail and edit an implicit prerequisite.
-
docs/source/likeperson.md · line 292- Contact detail, edit, and peer mentor profile screens
-
docs/source/likeperson.md · line 304- Optimistic mutations with automatic rollback on failure (contact edits and paginated list updates)
Responsibilities
- Load full contact profile from Drift database and emit hydrated state to UI screens
- Apply optimistic updates to local Drift records immediately on save events
- Enqueue changed contact records to the offline sync queue for REST API synchronisation
- Listen for sync failure events and trigger automatic rollback of affected local records
- Emit distinct states for loading, loaded, saving, rollback, and error conditions
Interfaces
loadContact(contactId: String): void
saveContact(form: ContactForm): void
onSyncResult(result: SyncResult): void
state: Stream<ContactState>
close(): void
Related Data Entities (3)
Data entities managed by this component