Ensure that data is initially uploaded; include nbt type in patch message block

This commit is contained in:
zontreck 2025-07-22 14:28:57 -07:00
parent 3756383fa8
commit 0a11b38856
4 changed files with 16 additions and 3 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.36";
static const VERSION = "1.0.0-beta.37";
static bool UPDATE_AVAILABLE = false;
static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta;

View file

@ -209,6 +209,7 @@ class SessionData {
var packet = json.encode({
"cmd": "patch",
"id": LastSessionID,
"type": "nbt",
"data": base64.encode(await NbtIo.writeToStream(data)),
});
var reply = await dio.post(TTConsts.SESSION_SERVER, data: packet);
@ -279,7 +280,7 @@ class SessionData {
);
}
await _create();
if (LastSessionID.isEmpty) await _create();
_listener = Geolocator.getPositionStream(
locationSettings: TTConsts.LOCATION_SETTINGS,
@ -300,6 +301,9 @@ class SessionData {
}
});
// initial data upload
_performPatch();
return true;
}
@ -462,6 +466,10 @@ class SessionData {
static Future<void> _deserialize(CompoundTag ct) async {
IsOnTheClock = NbtUtils.readBoolean(ct, "inprog");
if (ct.containsKey("sessionId") && !isWeb)
LastSessionID = ct.get("sessionId")!.asString();
if (ct.containsKey("record"))
Recording = NbtUtils.readBoolean(ct, "record");
else
@ -514,6 +522,9 @@ class SessionData {
CompoundTag ct = CompoundTag();
NbtUtils.writeBoolean(ct, "inprog", IsOnTheClock);
ct.put("sessionId", StringTag.valueOf(LastSessionID));
NbtUtils.writeBoolean(ct, "record", Recording);
// No need to write the contains trip times flag, it is set during deserialization. For inprog sessions, it will be set to true by the system.
ct.put("start", StringTag.valueOf(StartTime.toIso8601String()));

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.36
version: 1.0.0-beta.37
environment:
sdk: ^3.7.2

View file

@ -94,6 +94,7 @@ function pushNewData($DB, $sessionId, $data) {
$stmt = $DB->prepare("UPDATE `data` SET `SessionData` = ? WHERE `ID` = ?");
$stmt->bind_param("bs", $null, $sessionId);
$stmt->send_long_data(0, $data);
if(!$stmt->execute()) {
return false;
}
@ -125,6 +126,7 @@ switch($jsx['cmd']) {
// Not AI Generated
case "patch": {
$sessionId = $jsx['id'];
$data = NULL; // define the data variable.
if($jsx['type'] == "json") {
$data = json_encode($jsx['data']);