-
Notifications
You must be signed in to change notification settings - Fork 1.2k
#2645: Only update the threadLastSeen if its later than the current one #2699
#2645: Only update the threadLastSeen if its later than the current one #2699
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much, this is great! Just one tiny nitpick to make sure we don't encounter annoying bugs, then we'll be good 💯
@@ -29,6 +29,17 @@ export default async (job: Job<UserThreadLastSeenJobData>) => { | |||
const record = await getUsersThread(userId, threadId); | |||
|
|||
if (record) { | |||
if (record.lastSeen > date) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure to wrap these in new Date
calls since they might be unix timestamps or date objects and we might be comparing proverbial apples to oranges:
if (new Date(record.lastSeen).getTime() > new Date(date).getTime())
shared/types.js
Outdated
@@ -328,6 +328,7 @@ export type DBUsersThreads = { | |||
receiveNotifications: boolean, | |||
threadId: string, | |||
userId: string, | |||
lastSeen: Date, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be lastSeen: Date | number
because I'm not certain we always store Dates in the db. (and not unix timestamps) Mind trying that and seeing if it breaks things? If it does, don't worry about it.
Thank you! Now flow fails due to a typing error, I think you'll just have to change |
Hmm that Flow error is very weird. I'll try figuring it out locally, one sec. |
I tried the same thing, but that throws another error. I think Flow wants us to explicitly check whether |
Could that be it? |
Sorry, only just seen your replies! I'll give that a go later. |
No worries—if you can't fix that flow error just mark it as |
The flow issue here is pretty weird, I dug into it last night. Basically if we change the type def to the callsite of the Before: const record = await getUsersThread(userId, threadId); After: const record: ?DBUsersThreads = await getUsersThread(userId, threadId); Then there will be a flow issue on line 39 where it cant coerce |
Ref: facebook/flow#5294 |
Thanks for the fixes! We're working on the failing e2e tests in #2674 |
Status
Deploy after merge (delete what needn't be deployed)