Improve entries page and latest changes panel, units on events and timeline
All checks were successful
Release / meta (push) Successful in 9s
Release / linux-build (push) Successful in 8m3s
Release / android-build (push) Successful in 19m21s
Release / release-master (push) Successful in 40s
Release / release-dev (push) Successful in 42s

This commit is contained in:
2025-12-23 17:41:21 +00:00
parent 29959f7580
commit 44d79e7c28
16 changed files with 1764 additions and 498 deletions

View File

@@ -48,6 +48,9 @@ class DataService extends ChangeNotifier {
List<LocoChange> get latestLocoChanges => _latestLocoChanges;
bool _isLatestLocoChangesLoading = false;
bool get isLatestLocoChangesLoading => _isLatestLocoChangesLoading;
bool _latestLocoChangesHasMore = false;
bool get latestLocoChangesHasMore => _latestLocoChangesHasMore;
int _latestLocoChangesFetched = 0;
final Map<int, List<LocoAttrVersion>> _locoTimelines = {};
final Map<int, bool> _isLocoTimelineLoading = {};
List<LocoAttrVersion> timelineForLoco(int locoId) =>

View File

@@ -115,7 +115,11 @@ extension DataServiceTraction on DataService {
return _locoClasses;
}
Future<void> fetchLatestLocoChanges({int limit = 25, int offset = 0}) async {
Future<void> fetchLatestLocoChanges({
int limit = 100,
int offset = 0,
bool append = false,
}) async {
_isLatestLocoChangesLoading = true;
_notifyAsync();
try {
@@ -138,16 +142,41 @@ extension DataServiceTraction on DataService {
);
}
}
_latestLocoChanges = parsed;
if (append) {
_latestLocoChanges = [..._latestLocoChanges, ...parsed];
} else {
_latestLocoChanges = parsed;
}
final fetchedCount = parsed.length;
_latestLocoChangesFetched = append
? offset + fetchedCount
: fetchedCount;
_latestLocoChangesHasMore = _latestLocoChangesFetched < 5000;
} else {
throw Exception('Unexpected latest loco changes response: $json');
}
} catch (e) {
debugPrint('Failed to fetch latest loco changes: $e');
_latestLocoChanges = [];
_latestLocoChangesHasMore = false;
_latestLocoChangesFetched = 0;
} finally {
_isLatestLocoChangesLoading = false;
_notifyAsync();
}
}
Future<Map<String, dynamic>?> fetchClassStats(String locoClass) async {
try {
final path = Uri.encodeComponent(locoClass);
final json = await api.get('/loco/class/stats/$path/user');
if (json is Map) {
return Map<String, dynamic>.from(json);
}
debugPrint('Unexpected class stats response for $locoClass: $json');
} catch (e) {
debugPrint('Failed to fetch class stats for $locoClass: $e');
}
return null;
}
}