From cf0125755ccf4b0d20a0ad0b9b2a3f46c4fc6485 Mon Sep 17 00:00:00 2001 From: William Oldham Date: Wed, 6 Dec 2023 19:55:09 +0000 Subject: [PATCH] Use date to compare progress items --- src/routes/users/progress.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/routes/users/progress.ts b/src/routes/users/progress.ts index cc3e649..fbeb4e5 100644 --- a/src/routes/users/progress.ts +++ b/src/routes/users/progress.ts @@ -100,10 +100,9 @@ export const userProgressRouter = makeRouter((app) => { if (newItemIndex > -1) { const newItem = newItems[newItemIndex]; - if (existingItem.watched < newItem.watched) { - existingItem.updatedAt = defaultAndCoerceDateTime( - newItem.updatedAt, - ); + const newItemDate = defaultAndCoerceDateTime(newItem.updatedAt); + if (existingItem.updatedAt.getTime() < newItemDate.getTime()) { + existingItem.updatedAt = newItemDate; existingItem.watched = newItem.watched; } itemsUpserted.push(existingItem);