Skip to content

Commit 3b81985

Browse files
Copilotolgahaha
andcommitted
Fix incorrect asset date by adding timestamp conversion in timestamp getter
Co-authored-by: olgahaha <1139711+olgahaha@users.noreply.github.com>
1 parent f687359 commit 3b81985

File tree

1 file changed

+13
-12
lines changed
  • src/app/shared/repositories/proof

1 file changed

+13
-12
lines changed

src/app/shared/repositories/proof/proof.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,12 @@ export class Proof {
5858

5959
/**
6060
* Used to sort the assets in the VERIFIED tab either by timestamp or uploadedAt (if available).
61+
* Since timestamp getter now ensures values are always in milliseconds, we don't need
62+
* to perform the seconds-to-milliseconds conversion here.
6163
*/
6264
get uploadedAtOrTimestamp() {
63-
const MILLISECONDS_PER_SECOND = 1000;
64-
const MILLISECONDS_THRESHOLD = 10000000000; // 10^10, timestamps after March 2001
65-
66-
// convert timestamp to milliseconds if needed
67-
// Use threshold-based approach instead of string length to determine if timestamp is in milliseconds
68-
const proofTimestampInMilliseconds =
69-
this.timestamp > MILLISECONDS_THRESHOLD
70-
? this.timestamp
71-
: this.timestamp * MILLISECONDS_PER_SECOND;
72-
7365
const serverTimestampInMilliseconds = Date.parse(this.uploadedAt ?? '');
74-
return serverTimestampInMilliseconds || proofTimestampInMilliseconds;
66+
return serverTimestampInMilliseconds || this.timestamp;
7567
}
7668

7769
/**
@@ -83,9 +75,18 @@ export class Proof {
8375
*
8476
* Note: Milliseconds are typically 13 digits long (after 2001), while seconds are typically 10 digits long.
8577
* We use a threshold-based approach to detect and convert between these formats.
78+
*
79+
* This getter ensures timestamps are always returned in milliseconds regardless of
80+
* how they're stored (seconds or milliseconds).
8681
*/
8782
get timestamp() {
88-
return this.truth.timestamp;
83+
const MILLISECONDS_PER_SECOND = 1000;
84+
const MILLISECONDS_THRESHOLD = 10000000000; // 10^10, timestamps after March 2001
85+
86+
// Convert to milliseconds if the timestamp is in seconds
87+
return this.truth.timestamp > MILLISECONDS_THRESHOLD
88+
? this.truth.timestamp
89+
: this.truth.timestamp * MILLISECONDS_PER_SECOND;
8990
}
9091

9192
get deviceName() {

0 commit comments

Comments
 (0)