Skip to content

feat(web): hide sub-minute calendar entries (from upstream PR #110)#5

Merged
gbumanzordev merged 2 commits into
masterfrom
feat/calendar-hide-short-sessions-cherry
Apr 29, 2026
Merged

feat(web): hide sub-minute calendar entries (from upstream PR #110)#5
gbumanzordev merged 2 commits into
masterfrom
feat/calendar-hide-short-sessions-cherry

Conversation

@gbumanzordev
Copy link
Copy Markdown
Owner

Cherry-picks the two commits from GeorgeSG/KoInsight#110 onto our master:

  • 296b143 feat(web): add toggle to hide sub-minute calendar entries
  • e5f660b chore(server): seed sub-minute reading sessions

Why

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

  • Cherry-pick applied cleanly with no conflicts.
  • Type check / build passes.

🤖 Generated with Claude Code

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 20:43
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ko-insight-server Error Error Apr 29, 2026 8:43pm

@gbumanzordev gbumanzordev merged commit 8b93dca into master Apr 29, 2026
3 of 4 checks passed
@gbumanzordev gbumanzordev deleted the feat/calendar-hide-short-sessions-cherry branch April 29, 2026 20:44
Copy link
Copy Markdown

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 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);
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 124 to 126
<Calendar<DayData>
events={calendarEvents}
dayRenderer={(data) => getBookNames(data).map((el) => <div>{el}</div>)}
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
acc[key].data = acc[key]?.data?.events
? { events: [...acc[key].data.events, event] }
: { events: [event] };
const [hideEmpty, setHideEmpty] = useState(false);
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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,
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
// 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,

Copilot uses AI. Check for mistakes.
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