chore: normalize creation and update timestamps on payloads (#2731)

This commit is contained in:
Karol Sójko
2023-12-28 10:16:20 +01:00
committed by GitHub
parent c43f029381
commit 7a8fc49d86

View File

@@ -62,12 +62,22 @@ export abstract class PurePayload<T extends TransferPayload<C>, C extends ItemCo
this.dirty = rawPayload.dirty
this.duplicate_of = rawPayload.duplicate_of
this.created_at = new Date(rawPayload.created_at || new Date())
this.updated_at = new Date(rawPayload.updated_at || 0)
this.created_at_timestamp = rawPayload.created_at_timestamp || 0
this.updated_at_timestamp = rawPayload.updated_at_timestamp || 0
if (this.updated_at_timestamp < 0) {
this.updated_at_timestamp = 0
this.updated_at = new Date(0)
}
this.created_at = new Date(rawPayload.created_at || new Date())
this.created_at_timestamp = rawPayload.created_at_timestamp || 0
if (this.created_at_timestamp < 0) {
this.created_at_timestamp = this.updated_at_timestamp
this.created_at = this.updated_at
}
this.lastSyncBegan = rawPayload.lastSyncBegan ? new Date(rawPayload.lastSyncBegan) : undefined
this.lastSyncEnd = rawPayload.lastSyncEnd ? new Date(rawPayload.lastSyncEnd) : undefined