new pipeline
Some checks failed
Release / meta (push) Successful in 2s
Release / android-build (push) Failing after 15s
Release / linux-build (push) Failing after 34s
Release / windows-build (push) Has been cancelled
Release / release-dev (push) Has been cancelled
Release / release-master (push) Has been cancelled
Some checks failed
Release / meta (push) Successful in 2s
Release / android-build (push) Failing after 15s
Release / linux-build (push) Failing after 34s
Release / windows-build (push) Has been cancelled
Release / release-dev (push) Has been cancelled
Release / release-master (push) Has been cancelled
This commit is contained in:
@@ -5,11 +5,29 @@ import 'package:flutter/scheduler.dart';
|
||||
import 'package:mileograph_flutter/objects/objects.dart';
|
||||
import 'package:mileograph_flutter/services/apiService.dart'; // assumes you've moved HomepageStats + submodels to a separate file
|
||||
|
||||
class _LegFetchOptions {
|
||||
final int limit;
|
||||
final String sortBy;
|
||||
final int sortDirection;
|
||||
final String? dateRangeStart;
|
||||
final String? dateRangeEnd;
|
||||
|
||||
const _LegFetchOptions({
|
||||
this.limit = 100,
|
||||
this.sortBy = 'date',
|
||||
this.sortDirection = 0,
|
||||
this.dateRangeStart,
|
||||
this.dateRangeEnd,
|
||||
});
|
||||
}
|
||||
|
||||
class DataService extends ChangeNotifier {
|
||||
final ApiService api;
|
||||
|
||||
DataService({required this.api});
|
||||
|
||||
_LegFetchOptions _lastLegsFetch = const _LegFetchOptions();
|
||||
|
||||
// Homepage Data
|
||||
HomepageStats? _homepageStats;
|
||||
HomepageStats? get homepageStats => _homepageStats;
|
||||
@@ -89,6 +107,15 @@ class DataService extends ChangeNotifier {
|
||||
bool append = false,
|
||||
}) async {
|
||||
_isLegsLoading = true;
|
||||
if (!append) {
|
||||
_lastLegsFetch = _LegFetchOptions(
|
||||
limit: limit,
|
||||
sortBy: sortBy,
|
||||
sortDirection: sortDirection,
|
||||
dateRangeStart: dateRangeStart,
|
||||
dateRangeEnd: dateRangeEnd,
|
||||
);
|
||||
}
|
||||
final buffer = StringBuffer(
|
||||
'?sort_direction=$sortDirection&sort_by=$sortBy&offset=$offset&limit=$limit');
|
||||
if (dateRangeStart != null && dateRangeStart.isNotEmpty) {
|
||||
@@ -117,6 +144,16 @@ class DataService extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> refreshLegs() {
|
||||
return fetchLegs(
|
||||
limit: _lastLegsFetch.limit,
|
||||
sortBy: _lastLegsFetch.sortBy,
|
||||
sortDirection: _lastLegsFetch.sortDirection,
|
||||
dateRangeStart: _lastLegsFetch.dateRangeStart,
|
||||
dateRangeEnd: _lastLegsFetch.dateRangeEnd,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> fetchHadTraction({int offset = 0, int limit = 100}) async {
|
||||
await fetchTraction(
|
||||
hadOnly: true,
|
||||
|
||||
Reference in New Issue
Block a user