Fix load app from cache

This commit is contained in:
zontreck 2025-05-25 13:45:17 -07:00
parent b1063f5057
commit 7b05ed2a4a
5 changed files with 19 additions and 13 deletions

View file

@ -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;

View file

@ -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<void> _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) {

View file

@ -17,6 +17,8 @@ void serviceEntry() {
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
SessionData.LoadSavedCacheState();
SessionData.isWeb = true;
try {
SessionData.isWeb = !Platform.isAndroid;

View file

@ -117,22 +117,15 @@ class _HomePageState extends State<HomePage> {
}
},
),
/*
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();
});
},
),*/
),
],
),
),

View file

@ -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