feat(offline): tier 2 phase 2 — extend cache to tasks/projects/milestones/events/conversations
Phase 1 cached only notes. Phase 2 brings the read-through pattern to every domain the app reads in bulk: - Drift schema v2: 5 new cached_* tables + onUpgrade migration. Calendar events use range-scoped read/write (replaceEventsInRange) so disjoint month fetches don't clobber each other; milestones are per-project. - Wrap TasksRepository, ProjectsRepository, MilestonesRepository, and ChatRepository (conversation list only) with NetworkException fallback. Writes hit the API then sync the cache. - New EventsRepository wrapping EventsApi; calendar_provider and event_form_sheet repointed at the repository. - OfflineBanner now surfaces getLatestSync() — most-recent timestamp across all domains — so the hint reads sensibly regardless of screen. flutter analyze clean; existing tests pass. Phase 3 (offline write queue) and Phase 4 (read-only UI indicators) still to come. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -120,12 +120,12 @@ class _EventFormSheetState extends ConsumerState<EventFormSheet> {
|
||||
'color': _color,
|
||||
'recurrence': rrule,
|
||||
};
|
||||
final api = ref.read(eventsApiProvider);
|
||||
final repo = ref.read(eventsRepositoryProvider);
|
||||
if (_isCreate) {
|
||||
final created = await api.createEvent(payload);
|
||||
final created = await repo.createEvent(payload);
|
||||
widget.notifier.addEvent(created);
|
||||
} else {
|
||||
final updated = await api.updateEvent(widget.event!.id, payload);
|
||||
final updated = await repo.updateEvent(widget.event!.id, payload);
|
||||
widget.notifier.updateEvent(updated);
|
||||
}
|
||||
if (mounted) Navigator.of(context).pop();
|
||||
@@ -165,7 +165,7 @@ class _EventFormSheetState extends ConsumerState<EventFormSheet> {
|
||||
if (confirmed != true || !mounted) return;
|
||||
setState(() => _saving = true);
|
||||
try {
|
||||
await ref.read(eventsApiProvider).deleteEvent(widget.event!.id);
|
||||
await ref.read(eventsRepositoryProvider).deleteEvent(widget.event!.id);
|
||||
widget.notifier.removeEvent(widget.event!.id, widget.event!.startDt);
|
||||
if (mounted) Navigator.of(context).pop();
|
||||
} catch (_) {
|
||||
|
||||
Reference in New Issue
Block a user