Activities Repository
Component Detail
Description
Drift (SQLite) local data access object for the activities table on the mobile client. Implements the offline-first mutation pattern - writes land immediately in the local DB and are added to the mutation outbox for background sync. Provides reactive streams so the Quick Log Screen can observe save state without polling.
activities-repository
Sources & reasoning
The offline-first requirement means all activity writes must go through a local Drift repository before reaching the server. This component is shared because every activity-producing feature (simple logging, wizard, proxy registration) reads and writes the same local activities table via the same DAO pattern.
No source references — this artifact was included based on reasoning alone (see above).
Responsibilities
- Insert activity records into the local Drift activities table
- Enqueue new records in the mutation outbox for background sync
- Expose a reactive stream of recent activities for the current user
- Handle ID mapping when the server assigns a canonical ID to an offline-created record
Interfaces
insertActivity(ActivityCompanion) → Future<int>
watchRecentActivities(String userId) → Stream<List<Activity>>
markSynced(int localId, String serverId) → Future<void>
getPendingOutbox() → Future<List<Activity>>