diff options
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/db/repositories.test.ts | 3 | ||||
| -rw-r--r-- | src/client/db/repositories.ts | 5 | ||||
| -rw-r--r-- | src/client/pages/DeckDetailPage.tsx | 7 |
3 files changed, 9 insertions, 6 deletions
diff --git a/src/client/db/repositories.test.ts b/src/client/db/repositories.test.ts index 448cb9e..38cf3fb 100644 --- a/src/client/db/repositories.test.ts +++ b/src/client/db/repositories.test.ts @@ -299,7 +299,8 @@ describe("localCardRepository", () => { describe("findDueCards", () => { it("should return cards that are due", async () => { const pastDue = new Date(Date.now() - 60000); - const future = new Date(Date.now() + 60000); + // Use a date far enough in the future to be beyond the next 3 AM boundary + const future = new Date(Date.now() + 2 * 24 * 60 * 60 * 1000); const card1 = await localCardRepository.create({ deckId, diff --git a/src/client/db/repositories.ts b/src/client/db/repositories.ts index e01254e..5121bae 100644 --- a/src/client/db/repositories.ts +++ b/src/client/db/repositories.ts @@ -1,4 +1,5 @@ import { v4 as uuidv4 } from "uuid"; +import { getEndOfStudyDayBoundary } from "../../shared/date"; import { CardState, db, @@ -140,11 +141,11 @@ export const localCardRepository = { * Get due cards for a deck */ async findDueCards(deckId: string, limit?: number): Promise<LocalCard[]> { - const now = new Date(); + const boundary = getEndOfStudyDayBoundary(); const query = db.cards .where("deckId") .equals(deckId) - .filter((card) => card.deletedAt === null && card.due <= now); + .filter((card) => card.deletedAt === null && card.due < boundary); const cards = await query.toArray(); // Sort by due date ascending diff --git a/src/client/pages/DeckDetailPage.tsx b/src/client/pages/DeckDetailPage.tsx index be4dc90..97f8378 100644 --- a/src/client/pages/DeckDetailPage.tsx +++ b/src/client/pages/DeckDetailPage.tsx @@ -7,6 +7,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useAtomValue } from "jotai"; import { Suspense } from "react"; import { Link, useParams } from "wouter"; +import { getEndOfStudyDayBoundary } from "../../shared/date"; import { cardsByDeckAtomFamily, deckByIdAtomFamily } from "../atoms"; import { ErrorBoundary } from "../components/ErrorBoundary"; import { LoadingSpinner } from "../components/LoadingSpinner"; @@ -27,9 +28,9 @@ function DeckHeader({ deckId }: { deckId: string }) { function DeckStats({ deckId }: { deckId: string }) { const { data: cards } = useAtomValue(cardsByDeckAtomFamily(deckId)); - // Count cards due today - const now = new Date(); - const dueCards = cards.filter((card) => new Date(card.due) <= now); + // Count cards due today (study day boundary is 3:00 AM) + const boundary = getEndOfStudyDayBoundary(); + const dueCards = cards.filter((card) => new Date(card.due) < boundary); return ( <div className="bg-white rounded-xl border border-border/50 p-6 mb-6"> |
