fix: use created_at for unsynced session history entries#305
fix: use created_at for unsynced session history entries#305
Conversation
8f0fe47 to
a42296f
Compare
029de60 to
35bb43d
Compare
| protected readonly hasPreviousEntry: boolean; | ||
|
|
||
| constructor(payload: SurePayload, previousEntry?: HistoryEntry) { | ||
| const updated_at = payload.serverUpdatedAt ?? new Date(); |
There was a problem hiding this comment.
Hmm, here we are creating new Date(), which is the present date, but in the constructor of pure_payload we are defaulting to new Date(0), which is 1970. Is this intended? So seems like here after this change if updated_at is nil then entry will default to 1970 rather than present.
There was a problem hiding this comment.
There's a bug with this line in that payload.serverUpdatedAt is always truthy, because the pure_payload constructor always creates a date object. So updated_at can never be new Date().
I don't know what the original intent was, but I think a history entry making up dates is more confusing than helpful. updated_at being equal to the time of construction does not make sense with how the rest of the code treats that kind of field
More broadly speaking I'm not sure setting a payload's updated_at to 1/1/1970 by default is a very accurate way to describe an unsynced payload, but I may be missing something
There was a problem hiding this comment.
I think the intent is that if creating a new entry, the present time is likely the right time for its creation. But this applies only to the offline use case. I suppose as long as you've tested this functionality in the web app while not signed into an account, and it shows the right date, then all is good.
9c18d19 to
db6ddb2
Compare
See standardnotes/mobile#432