Skip to content

Commit e9f9ec0

Browse files
author
danny
committed
Setting initial import to 1970 to fix sorting reports into history
1 parent 6ec7420 commit e9f9ec0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

macless_haystack/lib/accessory/accessory_registry.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ class AccessoryRegistry extends ChangeNotifier {
231231
//Update the latest timestamp
232232
if (decryptedReports.isNotEmpty) {
233233
var lastReport = decryptedReports[decryptedReports.length - 1];
234-
var oldTs = DateTime(1970);
235-
var latestReportTS = lastReport.timestamp ?? DateTime(1971);
236-
if (oldTs.isBefore(latestReportTS)) {
234+
var oldTs = accessory.datePublished;
235+
var latestReportTS = lastReport.timestamp ?? lastReport.published ?? DateTime(1971);
236+
if (oldTs == null || oldTs.isBefore(latestReportTS) ) {
237237
//only an actualization if oldTS is not set or is older than the latest of the new ones
238238
accessory.lastLocation =
239239
LatLng(lastReport.latitude!, lastReport.longitude!);

macless_haystack/lib/item_management/item_file_import.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class _ItemFileImportState extends State<ItemFileImport> {
143143
var keyPair = await FindMyController.importKeyPair(accessoryDTO.privateKey);
144144

145145
Accessory newAccessory = Accessory(
146-
datePublished: DateTime.now(),
146+
datePublished: DateTime(1970),
147147
hashedPublicKey: keyPair.hashedPublicKey,
148148
id: accessoryDTO.id.toString(),
149149
name: accessoryDTO.name,

0 commit comments

Comments
 (0)