Skip to content

Commit 605eb40

Browse files
arbrandesclaude
andcommitted
fix: compute Date.now() per call instead of at module load
The fallback enrollment date was frozen when the module first loaded. If the app stayed open across midnight, courses with null lastEnrolled would get a stale timestamp. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b15aa3d commit 605eb40

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/utils/dataTransformers.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ import { FilterKeys, ListPageSize, SortKeys } from '@src/data/constants/app';
22
import StrictDict from './StrictDict';
33

44
const cardId = (val) => `card-${val}`;
5-
const today = Date.now();
65

7-
const transformCourseData = (courses) => courses.reduce(
6+
const transformCourseData = (courses) => {
7+
const now = Date.now();
8+
return courses.reduce(
89
(obj, curr, index) => {
910
const out = { ...curr, cardId: cardId(index) };
1011
if (out.enrollment?.lastEnrolled === null) {
11-
out.enrollment.lastEnrolled = today;
12+
out.enrollment.lastEnrolled = now;
1213
}
1314
return { ...obj, [cardId(index)]: out };
1415
},
1516
{},
1617
);
18+
};
1719

1820
const getTransformedCourseDataObject = (courses) => transformCourseData(courses);
1921

0 commit comments

Comments
 (0)