Public Access
feat(ui): filter for station arrivals after start
This commit is contained in:
+12
-3
@@ -202,6 +202,7 @@ class ApiHandler {
|
||||
int? fromIdx,
|
||||
String? toId,
|
||||
int? toIdx,
|
||||
String? startStationId,
|
||||
}) async {
|
||||
String urlPath = '/api/fahrinfo/latest/journeyDetail';
|
||||
Uri url = Uri.https(baseUrl, urlPath, {
|
||||
@@ -216,7 +217,7 @@ class ApiHandler {
|
||||
);
|
||||
final httpPackageJson =
|
||||
json.decode(jsonResponse.body) as Map<String, dynamic>;
|
||||
final DepartureList = httpPackageJson["Stops"]["Stop"]
|
||||
Iterable<Departure> DepartureList = httpPackageJson["Stops"]["Stop"]
|
||||
.map(
|
||||
(x) => Departure.fromJson(
|
||||
// needed because I'm too lazy to write a second mostly identical
|
||||
@@ -224,9 +225,17 @@ class ApiHandler {
|
||||
_expandDeparturesJson(httpPackageJson, x, ["ref", "Product"]),
|
||||
),
|
||||
)
|
||||
.toList()
|
||||
.cast<Departure>();
|
||||
return DepartureList;
|
||||
|
||||
// preferably this happens always?
|
||||
if (startStationId != null) {
|
||||
// show Stations after the one we are at
|
||||
return DepartureList.skipWhile(
|
||||
(x) => x.stationId != startStationId,
|
||||
).skip(1).toList();
|
||||
}
|
||||
|
||||
return DepartureList.toList().cast<Departure>();
|
||||
}
|
||||
|
||||
// workaround for the fact that json from tripDetail and DepartureBoard are
|
||||
|
||||
Reference in New Issue
Block a user