From 7b05ed2a4ad5080c25cffbeab52aa4cefb8af36c Mon Sep 17 00:00:00 2001 From: zontreck Date: Sun, 25 May 2025 13:45:17 -0700 Subject: [PATCH] Fix load app from cache --- lib/consts.dart | 2 +- lib/data.dart | 13 ++++++++++++- lib/main.dart | 2 ++ lib/pages/HomePage.dart | 13 +++---------- pubspec.yaml | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/consts.dart b/lib/consts.dart index 09ea71f..6da94be 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -9,7 +9,7 @@ class TTConsts { static get SESSION_SERVER => "https://api.zontreck.com/timetrack/$UPDATE_CHANNEL/timetrack.php"; - static const VERSION = "1.0.0-beta.18"; + static const VERSION = "1.0.0-beta.19"; static bool UPDATE_AVAILABLE = false; static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta; diff --git a/lib/data.dart b/lib/data.dart index 54f8845..b9a2ef6 100644 --- a/lib/data.dart +++ b/lib/data.dart @@ -327,6 +327,10 @@ class SessionData { await _deserialize(ct); + if (IsOnTheClock) ContainsTripTimes = true; + + Calls.dispatch(); + return true; } @@ -338,13 +342,20 @@ class SessionData { static Future _deserialize(CompoundTag ct) async { IsOnTheClock = NbtUtils.readBoolean(ct, "inprog"); + + if (IsOnTheClock) { + await Login(); + } + StartTime = DateTime.parse(ct.get("start")!.asString()); if (ct.containsKey("end")) { EndTime = DateTime.parse(ct.get("end")!.asString()); } else { EndTime = DateTime(0); } - TotalPay = ct.get("totalPay")!.asDouble(); + if (ct.containsKey("totalPay")) { + TotalPay = ct.get("totalPay")!.asDouble(); + } ListTag poses = ct.get("pos")! as ListTag; for (var pos in poses.value) { diff --git a/lib/main.dart b/lib/main.dart index b1ab326..b5bed5c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -17,6 +17,8 @@ void serviceEntry() { Future main() async { WidgetsFlutterBinding.ensureInitialized(); + SessionData.LoadSavedCacheState(); + SessionData.isWeb = true; try { SessionData.isWeb = !Platform.isAndroid; diff --git a/lib/pages/HomePage.dart b/lib/pages/HomePage.dart index 4d8c71b..88ac22f 100644 --- a/lib/pages/HomePage.dart +++ b/lib/pages/HomePage.dart @@ -117,22 +117,15 @@ class _HomePageState extends State { } }, ), - /* + ListTile( title: Text("RESET APP SESSION"), onTap: () async { setState(() { - SessionData.IsOnTheClock = false; - SessionData.StartTime = DateTime.fromMillisecondsSinceEpoch( - 0, - ); - SessionData.Trips = []; - SessionData.currentDelivery = null; - SessionData.currentTrip = null; - SessionData.positions = []; + SessionData.ResetAppSession(); }); }, - ),*/ + ), ], ), ), diff --git a/pubspec.yaml b/pubspec.yaml index 0db30e5..e8174c1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.0-beta.18 +version: 1.0.0-beta.19 environment: sdk: ^3.7.2