diff --git a/lib/transport_helper.dart b/lib/transport_helper.dart index 13d162e..feec1de 100644 --- a/lib/transport_helper.dart +++ b/lib/transport_helper.dart @@ -1,4 +1,5 @@ import 'package:sqflite/sqflite.dart'; +import 'utilities.dart'; // import './state_helper.dart'; // import './db_helper.dart'; @@ -94,13 +95,15 @@ class Journey { Map journeyMaps, List segmentMaps, ) { - return Journey( + Journey journey = Journey( id: journeyMaps["id"] as int, startStation: journeyMaps["startstation"] as String?, endStation: journeyMaps["endstation"] as String?, segments: segmentMaps, duration: Duration(minutes: 0), ); + journey.sync(); + return journey; } // from trip API request @@ -134,8 +137,8 @@ class Journey { if (segments.isNotEmpty) { startStation = segments.first.start.stationName; endStation = segments.last.end.stationName; - duration = segments.first.start.departureTime.difference( - segments.last.end.arrivalTime, + duration = segments.last.end.arrivalTime.difference( + segments.first.start.departureTime, ); } else { // if the journey has no segments yet, at least the startStation should remain, @@ -223,7 +226,6 @@ class Journey { static Future fromMapWrapper(Map journeyMap) async { Future> segs = _dbGetJourneySegments(journeyMap["id"] as int); Journey res = Journey.fromMap(journeyMap, await segs); - res.sync(); return res; }