feat(app): offline-кэш на остальных экранах — фаза 5
accounts, cashflow, categories, goals, income, portfolio (+instrument), rebalance, tax, rules переведены на Cached<T> по контракту docs/ai/offline-cache.md. Общие/второстепенные селекторы (scopesProvider, categoriesListProvider и т.п.) оставлены как есть — не основной контент экрана. sync_page.dart и settings_page.dart не тронуты (первый — заменён health-page отдельно, второй — чистые действия без списка для баннера).
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../core/api/api_client.dart';
|
||||
import '../../core/cache/cached.dart';
|
||||
import '../../core/utils/ru_date.dart';
|
||||
import '../../core/widgets/async_value_view.dart';
|
||||
import '../../core/widgets/empty_state.dart';
|
||||
@@ -13,8 +14,9 @@ final benchmarksApiProvider =
|
||||
Provider<BenchmarksApi>((ref) => BenchmarksApi(ref.watch(apiProvider).dio));
|
||||
|
||||
/// Benchmark comparison for the current scope. Part of Портфель, not a screen of its own:
|
||||
/// «на сколько я обогнал индекс» is a property of the portfolio, not a separate subject.
|
||||
final benchmarkRowsProvider = FutureProvider.autoDispose<List<BenchmarkRow>>((ref) async {
|
||||
/// «на сколько я обогнал индекс» is a property of the portfolio, not a separate subject. See
|
||||
/// `docs/ai/offline-cache.md`.
|
||||
final benchmarkRowsProvider = FutureProvider.autoDispose<Cached<List<BenchmarkRow>>>((ref) async {
|
||||
final scope = ref.watch(scopeProvider);
|
||||
return ref.watch(benchmarksApiProvider).compare(scope: scope);
|
||||
});
|
||||
@@ -34,7 +36,7 @@ class BenchmarksCard extends ConsumerWidget {
|
||||
return AsyncValueView(
|
||||
value: rows,
|
||||
onRetry: () => ref.invalidate(benchmarkRowsProvider),
|
||||
data: (data) => data.isEmpty
|
||||
data: (cached) => cached.data.isEmpty
|
||||
? const EmptyState(
|
||||
icon: Icons.compare_arrows,
|
||||
message: 'Бенчмарки не настроены — сравнивать не с чем.',
|
||||
@@ -42,7 +44,7 @@ class BenchmarksCard extends ConsumerWidget {
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (final row in data)
|
||||
for (final row in cached.data)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: _PeriodBlock(row: row),
|
||||
|
||||
Reference in New Issue
Block a user