getUnreadByConversationAndMarkRead: Take 'now' param for reliable tests

This commit is contained in:
Scott Nonnenberg 2022-09-22 16:49:06 -07:00 committed by GitHub
parent 77bf3a8669
commit a7253be213
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 3 deletions

View file

@ -2169,16 +2169,18 @@ async function getUnreadByConversationAndMarkRead({
newestUnreadAt,
storyId,
readAt,
now = Date.now(),
}: {
conversationId: string;
isGroup?: boolean;
newestUnreadAt: number;
storyId?: UUIDStringType;
readAt?: number;
now?: number;
}): Promise<GetUnreadByConversationAndMarkReadResultType> {
const db = getInstance();
return db.transaction(() => {
const expirationStartTimestamp = Math.min(Date.now(), readAt ?? Infinity);
const expirationStartTimestamp = Math.min(now, readAt ?? Infinity);
db.prepare<Query>(
`
UPDATE messages