From 680af0b8efd67e4c1fbe180433dcf64d646b832c Mon Sep 17 00:00:00 2001 From: Willian Wang Date: Wed, 30 Aug 2023 22:03:33 -0300 Subject: [PATCH] Fix last seen point --- lib/accessory/accessory_registry.dart | 2 ++ lib/findMy/decrypt_reports.dart | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/accessory/accessory_registry.dart b/lib/accessory/accessory_registry.dart index 0ff7814..5b8bd42 100644 --- a/lib/accessory/accessory_registry.dart +++ b/lib/accessory/accessory_registry.dart @@ -111,6 +111,8 @@ class AccessoryRegistry extends ChangeNotifier { )) .toList(); + reports.sort((a, b) => (b.timestamp ?? DateTime(0)).compareTo(a.timestamp ?? DateTime(0))); + if (reports.isNotEmpty) { var lastReport = reports.first; accessory.lastLocation = LatLng(lastReport.latitude, lastReport.longitude); diff --git a/lib/findMy/decrypt_reports.dart b/lib/findMy/decrypt_reports.dart index 7e587c1..6d551f0 100644 --- a/lib/findMy/decrypt_reports.dart +++ b/lib/findMy/decrypt_reports.dart @@ -51,6 +51,7 @@ class DecryptReports { final decryptedLocationChunk = reportChunk.mapIndexed((index, report) { final derivedKey = _kdf(sharedKeyChunk[index], ephemeralKeyChunk[index]); final payloadData = report.payload; + _decodeTimeAndConfidence(payloadData, report); final encData = payloadData.sublist(62, 72); final tag = payloadData.sublist(72, payloadData.length); final decryptedPayload = _decryptPayload(encData, derivedKey, tag);