feat(offline): tier 2 phase 4 — per-row pending-sync indicators
A small cloud-upload glyph appears next to any row whose id has a queued offline write (offline-created temp ids and pending edits both count). Tooltip reads "Pending sync — will save when online". Renders nothing during normal online operation so the list stays clean. - DB: `watchPendingIds(domain)` streams the union of target_id and temp_id across the queue, scoped per domain. - Per-domain Riverpod stream providers for notes / tasks / projects. - New `PendingSyncBadge` widget — used by KnowledgeItemCard (both list and grid variants), `_ProjectCard`, and `_TaskRow` in the project workspace. flutter analyze clean; 21 tests pass. Closes #147 — all four phases of Tier 2 offline mode are in place. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -573,6 +573,27 @@ class FabledDatabase extends _$FabledDatabase {
|
||||
);
|
||||
return query.watchSingle().map((row) => row.read<int>('c'));
|
||||
}
|
||||
|
||||
/// Watch the set of ids in [domain] that have a queued write (either a
|
||||
/// `target_id` for an update/delete or a `temp_id` for an offline create).
|
||||
/// Phase 4 — used by per-row pending-sync indicators in the list views.
|
||||
Stream<Set<int>> watchPendingIds(String domain) {
|
||||
final query = customSelect(
|
||||
'SELECT target_id, temp_id FROM pending_writes WHERE domain = ?',
|
||||
variables: [Variable.withString(domain)],
|
||||
readsFrom: {pendingWrites},
|
||||
);
|
||||
return query.watch().map((rows) {
|
||||
final ids = <int>{};
|
||||
for (final r in rows) {
|
||||
final t = r.read<int?>('target_id');
|
||||
final tmp = r.read<int?>('temp_id');
|
||||
if (t != null) ids.add(t);
|
||||
if (tmp != null) ids.add(tmp);
|
||||
}
|
||||
return ids;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ── Row ↔ model converters ──────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user