feat(web): hide sub-minute calendar entries (from upstream PR #110)#5
Conversation
KOReader sometimes records brief opens that surface as 00:00 totals on the calendar. Add a "Hide entries under a minute" switch on the calendar page and per-book calendar to filter those out.
Adds short "accidental open" page stats across recent days so the new calendar toggle has data to filter against during local development.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a UI toggle to hide calendar entries where total reading time is under one minute, reducing noise from KOReader “accidental opens”, and provides dev seed data to exercise the behavior.
Changes:
- Add a “Hide entries under a minute” switch + filtering logic to the global calendar view.
- Add the same switch + filtering logic to the per-book calendar view.
- Add a new server seed that creates short (5–24s) reading sessions across recent days for dev/testing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| apps/web/src/pages/calendar-page.tsx | Adds toggle state + filters per-day events so sub-minute per-book totals are hidden. |
| apps/web/src/pages/book-page/book-page-calendar.tsx | Adds toggle state + filters out days with < 60s total reading time for the selected book. |
| apps/server/src/db/seeds/08_short_sessions.ts | Seeds short sessions in recent history so the toggle has data to filter in dev. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| isLoading: eventsLoading, | ||
| } = usePageStats(); | ||
|
|
||
| const [hideEmpty, setHideEmpty] = useState(false); |
There was a problem hiding this comment.
hideEmpty is a misleading name for this toggle/state: the UI label and behavior are about hiding entries under 60 seconds, not empty days. Rename the state to something like hideUnderMinute / hideSubMinuteEntries (and matching setter) to avoid confusion when maintaining the filter logic.
| <Calendar<DayData> | ||
| events={calendarEvents} | ||
| dayRenderer={(data) => getBookNames(data).map((el) => <div>{el}</div>)} |
There was a problem hiding this comment.
dayRenderer wraps getBookNames(data) in a .map() that renders <div>{el}</div> without a key, which will trigger React key warnings and can cause unstable reconciliation. Consider returning the array directly (or have getBookNames return keyed elements) so each rendered item has a stable key (e.g., book id/md5).
| acc[key].data = acc[key]?.data?.events | ||
| ? { events: [...acc[key].data.events, event] } | ||
| : { events: [event] }; | ||
| const [hideEmpty, setHideEmpty] = useState(false); |
There was a problem hiding this comment.
hideEmpty is a misleading name for this toggle/state: the UI label and behavior are about hiding days with < 60 seconds of reading time. Rename to something like hideUnderMinute / hideSubMinuteDays to keep intent clear.
| const device = SEEDED_DEVICES.find((d) => d.id === bookDevice?.device_id); | ||
| if (!bookDevice || !device) return; | ||
|
|
||
| // Spread short sessions across the last 14 days, one per book per day, |
There was a problem hiding this comment.
The comment says "one per book per day", but the loop explicitly seeds only every 3rd day (if ((dayOffset + bookIndex) % 3 !== 0) continue;). Update the comment to match the actual cadence (every third day) so future changes don't get based on incorrect assumptions.
| // Spread short sessions across the last 14 days, one per book per day, | |
| // Spread short sessions across the last 14 days, one per book every third day, |
Cherry-picks the two commits from GeorgeSG/KoInsight#110 onto our
master:296b143feat(web): add toggle to hide sub-minute calendar entriese5f660bchore(server): seed sub-minute reading sessionsWhy
KOReader sometimes records brief opens that surface as 00:00 totals on the calendar. This adds a "Hide entries under a minute" switch on both the global calendar and the per-book calendar to filter those out.
Changes
apps/web/src/pages/book-page/book-page-calendar.tsx— adds the toggle and filter logic on the per-book view.apps/web/src/pages/calendar-page/...(touched in PR GeorgeSG#110) — same toggle on the global calendar.apps/server/src/db/seeds/08_short_sessions.ts(new) — seeds short "accidental open" page stats across the last 14 days for the first 6 books so the toggle has data to filter against in dev. Spreads 5-24 second sessions every third day per book.Verified
🤖 Generated with Claude Code