From 3aab8ccb4a7f240731ee9c32d539f1fa01d3297f Mon Sep 17 00:00:00 2001 From: Alex Tran Date: Sun, 22 Jan 2023 22:40:56 -0600 Subject: [PATCH] Correctly show current backup asset date when createdAt is in the year of 1970 --- .../modules/backup/services/backup.service.dart | 4 +++- .../backup/views/backup_controller_page.dart | 17 +++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mobile/lib/modules/backup/services/backup.service.dart b/mobile/lib/modules/backup/services/backup.service.dart index 02b0a6863b..deb16c55fc 100644 --- a/mobile/lib/modules/backup/services/backup.service.dart +++ b/mobile/lib/modules/backup/services/backup.service.dart @@ -274,7 +274,9 @@ class BackupService { setCurrentUploadAssetCb( CurrentUploadAsset( id: entity.id, - createdAt: entity.createDateTime, + createdAt: entity.createDateTime.year == 1970 + ? entity.modifiedDateTime + : entity.createDateTime, fileName: originalFileName, fileType: _getAssetType(entity.type), ), diff --git a/mobile/lib/modules/backup/views/backup_controller_page.dart b/mobile/lib/modules/backup/views/backup_controller_page.dart index c14f68d2f2..c8a15bcb16 100644 --- a/mobile/lib/modules/backup/views/backup_controller_page.dart +++ b/mobile/lib/modules/backup/views/backup_controller_page.dart @@ -468,6 +468,14 @@ class BackupControllerPage extends HookConsumerWidget { } buildCurrentBackupAssetInfoCard() { + String getAssetCreationDate() { + return DateFormat.yMMMMd('en_US').format( + DateTime.parse( + backupState.currentUploadAsset.createdAt.toString(), + ).toLocal(), + ); + } + return ListTile( leading: Icon( Icons.info_outline_rounded, @@ -576,14 +584,7 @@ class BackupControllerPage extends HookConsumerWidget { fontSize: 10.0, ), ).tr( - args: [ - DateFormat.yMMMMd('en_US').format( - DateTime.parse( - backupState.currentUploadAsset.createdAt - .toString(), - ).toLocal(), - ) - ], + args: [getAssetCreationDate()], ), ), ),