Improve entries page and latest changes panel, units on events and timeline
All checks were successful
All checks were successful
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user