From 3756383fa8108a4da3368b30d4236a3c8927e0e2 Mon Sep 17 00:00:00 2001 From: zontreck Date: Tue, 22 Jul 2025 13:31:30 -0700 Subject: [PATCH] Attempt to patch php patch method. --- lib/consts.dart | 2 +- lib/data.dart | 17 ++++++++--------- lib/pages/HomePage.dart | 24 ++++++++++++++++++++++++ pubspec.yaml | 2 +- server/php/timetrack.php | 3 ++- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/lib/consts.dart b/lib/consts.dart index b5d636d..565f3de 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.35"; + static const VERSION = "1.0.0-beta.36"; static bool UPDATE_AVAILABLE = false; static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta; diff --git a/lib/data.dart b/lib/data.dart index 00329e0..46b4e58 100644 --- a/lib/data.dart +++ b/lib/data.dart @@ -237,7 +237,7 @@ class SessionData { androidConfig: androidConfig, ); - FlutterBackground.enableBackgroundExecution(); + if (success) FlutterBackground.enableBackgroundExecution(); WakelockPlus.enable(); if (!success) { @@ -314,15 +314,14 @@ class SessionData { FlutterBackground.disableBackgroundExecution(); WakelockPlus.disable(); - var saveData = await _serializeToNBT(); - ResetAppSession(); - print(SnbtIo.writeToString(saveData)); - Uint8List nbtData = await NbtIo.writeToStream(saveData); + //var saveData = await _serializeToNBT(); + //ResetAppSession(); + //print(SnbtIo.writeToString(saveData)); + //Uint8List nbtData = await NbtIo.writeToStream(saveData); - Trips = []; - positions = []; + _performPatch(); - _upload(nbtData); + //_upload(nbtData); } /// v2 Create function. @@ -367,7 +366,7 @@ class SessionData { /// Deprecated: This function uploads using the v1 API, and is intended to be called at the conclusion of data recording. @Deprecated( - "This function utilizes the Protocol v1 Create method, which has been replaced by createv2 and patch. This function will be removed.", + "This function utilizes the Protocol v1 Create method, which has been replaced by createv2 and patch. This function will be removed. DO NOT USE", ) static Future _upload(List nbtData) async { Dio dio = Dio(); diff --git a/lib/pages/HomePage.dart b/lib/pages/HomePage.dart index a861ff7..dc91c7d 100644 --- a/lib/pages/HomePage.dart +++ b/lib/pages/HomePage.dart @@ -16,6 +16,8 @@ class HomePage extends StatefulWidget { } class _HomePageState extends State { + int UPLOAD_STATE = -1; + @override void didChangeDependencies() { setState(() {}); @@ -421,6 +423,8 @@ class _HomePageState extends State { SessionData.DirtyState = true; SessionData.ActionPerformed(); + + ShowUploadProgress(); }, child: Text("Yes"), ), @@ -446,6 +450,26 @@ class _HomePageState extends State { ); } + Future ShowUploadProgress() async { + UPLOAD_STATE = 0; + _advanceUpload(); + } + + Future _advanceUpload() async { + if (UPLOAD_STATE == 0) { + // We're now going to show the modal indicating the data is being compiled to NBT + showDialog( + context: context, + builder: (buildx) { + return AlertDialog.adaptive( + title: Text("Upload in progress"), + content: Column(children: [Text("Compiling NBT Session Data...")]), + ); + }, + ); + } + } + Widget GetLoggedInWidgets() { return Column( children: [ diff --git a/pubspec.yaml b/pubspec.yaml index 9085e1f..1270cda 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.35 +version: 1.0.0-beta.36 environment: sdk: ^3.7.2 diff --git a/server/php/timetrack.php b/server/php/timetrack.php index 43f39e4..67c2a4d 100644 --- a/server/php/timetrack.php +++ b/server/php/timetrack.php @@ -90,8 +90,9 @@ function update_version($DB, $sesisonId, $newVer) { } function pushNewData($DB, $sessionId, $data) { + $null = NULL; $stmt = $DB->prepare("UPDATE `data` SET `SessionData` = ? WHERE `ID` = ?"); - $stmt->bind_param("bs", NULL, $sessionId); + $stmt->bind_param("bs", $null, $sessionId); $stmt->send_long_data(0, $data); if(!$stmt->execute()) { return false;