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:
@@ -11,6 +11,7 @@ library;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../../core/cache/cached.dart';
|
||||
import '../../../core/utils/json.dart';
|
||||
|
||||
/// One expected (or already paid) payment.
|
||||
@@ -205,7 +206,9 @@ class IncomeApi {
|
||||
|
||||
static const _base = '/api/v1/income';
|
||||
|
||||
Future<IncomeCalendar> calendar({
|
||||
/// See `docs/ai/offline-cache.md`: this hand-written client returns `Cached<T>` directly
|
||||
/// (there is no generated `Response<T>` for the screen to unwrap `r.cached` from).
|
||||
Future<Cached<IncomeCalendar>> calendar({
|
||||
String scope = 'all',
|
||||
DateTime? dateFrom,
|
||||
DateTime? dateTo,
|
||||
@@ -217,10 +220,13 @@ class IncomeApi {
|
||||
'date_to': ?_isoDate(dateTo),
|
||||
'include_paid': includePaid,
|
||||
});
|
||||
return IncomeCalendar.fromJson(r.data ?? const {});
|
||||
return Cached(
|
||||
IncomeCalendar.fromJson(r.data ?? const {}),
|
||||
fetchedAt: r.extra['fetchedAt'] as DateTime?,
|
||||
);
|
||||
}
|
||||
|
||||
Future<IncomeHistory> history({
|
||||
Future<Cached<IncomeHistory>> history({
|
||||
String scope = 'all',
|
||||
String group = 'month',
|
||||
DateTime? dateFrom,
|
||||
@@ -234,15 +240,21 @@ class IncomeApi {
|
||||
'date_to': ?_isoDate(dateTo),
|
||||
'kind': ?kind,
|
||||
});
|
||||
return IncomeHistory.fromJson(r.data ?? const {});
|
||||
return Cached(
|
||||
IncomeHistory.fromJson(r.data ?? const {}),
|
||||
fetchedAt: r.extra['fetchedAt'] as DateTime?,
|
||||
);
|
||||
}
|
||||
|
||||
Future<IncomeForecast> forecast({String scope = 'all', int months = 12}) async {
|
||||
Future<Cached<IncomeForecast>> forecast({String scope = 'all', int months = 12}) async {
|
||||
final r = await _dio.get<Map<String, dynamic>>('$_base/forecast', queryParameters: {
|
||||
'scope': scope,
|
||||
'months': months,
|
||||
});
|
||||
return IncomeForecast.fromJson(r.data ?? const {});
|
||||
return Cached(
|
||||
IncomeForecast.fromJson(r.data ?? const {}),
|
||||
fetchedAt: r.extra['fetchedAt'] as DateTime?,
|
||||
);
|
||||
}
|
||||
|
||||
/// `format: date` on the wire. `DateQueryInterceptor` does this for the generated client;
|
||||
|
||||
Reference in New Issue
Block a user