Skip to content

feat(web): add toggle to hide sub-minute calendar entries#110

Open
gbumanzordev wants to merge 2 commits into
GeorgeSG:masterfrom
gbumanzordev:feat/calendar-hide-short-sessions
Open

feat(web): add toggle to hide sub-minute calendar entries#110
gbumanzordev wants to merge 2 commits into
GeorgeSG:masterfrom
gbumanzordev:feat/calendar-hide-short-sessions

Conversation

@gbumanzordev
Copy link
Copy Markdown

@gbumanzordev gbumanzordev commented Apr 29, 2026

Summary

KOReader occasionally records brief, accidental book opens. Those sessions surface on the KoInsight calendar as 00:00 entries (less than a minute of total reading time on that day), which clutters the month view, especially when the same day already has real reading activity on other books.

This PR adds an opt-in "Hide entries under a minute" toggle to both calendar views so those incidental opens can be filtered out without removing real data.

Changes

  • apps/web/src/pages/calendar-page.tsx
    • New Switch next to the page title.
    • When enabled, filters out per-book entries whose total daily duration is < 60s. Days that end up with no remaining books are dropped from the calendar entirely.
    • State is local to the page and defaults to off.
  • apps/web/src/pages/book-page/book-page-calendar.tsx
    • Same Switch placed above the per-book calendar.
    • When enabled, hides days where the book's total reading time is < 60s.
  • apps/server/src/db/seeds/08_short_sessions.ts (new)
    • Seeds 28 short (5-24s) "accidental open" page stats across the last 14 days for the first 6 books, so the new toggle has data to filter against during local development.

Rationale

Filtering happens client-side on the already-fetched stats, so there is no API or schema impact. Threshold (60s) matches the existing shortDuration formatter, which renders anything below a minute as 00:00, the exact rows users want to hide.

Screenshots

  • Before: calendar shows every accidental open as a 00:00 line under the day.
Screenshot 2026-04-29 at 10 13 36 AM
  • After (toggle on): days collapse to only the books with at least a minute of reading; days with nothing else disappear.
Screenshot 2026-04-29 at 10 13 43 AM

Test plan

  • npm run seed (in apps/server/) repopulates the dev DB, including the new short sessions.
  • Navigate to /calendar, confirm 00:00 entries are visible by default.
  • Flip "Hide entries under a minute" — sub-minute book entries disappear; days with only such entries collapse.
  • Open any book detail page, repeat the same check on the per-book calendar.
  • Toggle off; entries reappear.

Notes for reviewers

  • Seed file is independent of the toggle logic; happy to drop it from the PR if seed changes should land separately.
  • No new dependencies. Uses existing Mantine Switch and ramda.sum.

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.
Copilot AI review requested due to automatic review settings April 29, 2026 16:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in UI toggle in the web calendars to hide “00:00” clutter by filtering out per-day reading totals under 60 seconds, plus a dev seed to generate short sessions for local testing.

Changes:

  • Add “Hide entries under a minute” Switch to the main calendar page and filter out per-book daily totals < 60s (dropping days that become empty).
  • Add the same toggle to the per-book calendar and hide days where that book’s total is < 60s.
  • Add a new server seed to generate short “accidental open” sessions across recent days.

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 + client-side filtering of calendar events under 60 seconds.
apps/web/src/pages/book-page/book-page-calendar.tsx Adds toggle + per-book day filtering under 60 seconds.
apps/server/src/db/seeds/08_short_sessions.ts Seeds short sessions for local dev to exercise the new toggle.
Comments suppressed due to low confidence (1)

apps/web/src/pages/calendar-page.tsx:127

  • dayRenderer is rendering an array via .map(...) without providing a stable key prop on the returned elements, which will cause React "unique key" warnings and can lead to incorrect reconciliation. Consider returning elements with keys (e.g., key by book md5/id) rather than wrapping getBookNames(data) in a keyless <div> map (and note getBookNames itself maps to fragments without keys).
      <Calendar<DayData>
        events={calendarEvents}
        dayRenderer={(data) => getBookNames(data).map((el) => <div>{el}</div>)}
      />

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +58 to +60
const filtered = entry.data!.events.filter(
(event) => totalsByBook[event.book_md5] >= 60
);
Comment on lines +26 to +27
const [hideEmpty, setHideEmpty] = useState(false);

Comment on lines +39 to +41
const total = sum(entry.data!.events.map((event) => event.duration));
if (total >= 60) {
acc[key] = entry;
Comment on lines +19 to 20
const [hideEmpty, setHideEmpty] = useState(false);

gbumanzordev added a commit to gbumanzordev/KoInsight that referenced this pull request Apr 29, 2026
…ions-cherry

feat(web): hide sub-minute calendar entries (from upstream PR GeorgeSG#110)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants