这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@iboughtbed
Copy link
Collaborator

@iboughtbed iboughtbed commented May 26, 2025

  • feat: include calendar id into each event

Summary by CodeRabbit

  • New Features

    • Added the ability to hide or show specific calendars, with visibility preferences saved between sessions.
    • Introduced interactive checkboxes for toggling calendar visibility in the calendar list.
  • Improvements

    • Events are now associated with their respective calendar IDs, enabling more precise filtering and management.
    • Calendar views now only display events from visible calendars, improving clarity and customization.
  • Documentation

    • Added guidelines for managing persistent state and atom usage in the project.

* feat: include calendar id into each event
@vercel
Copy link

vercel bot commented May 26, 2025

@iboughtbed is attempting to deploy a commit to the Analog Interface Team on Vercel.

A member of the Team first needs to authorize it.

@JeanMeijer JeanMeijer requested a review from a-rebets May 26, 2025 12:36
Copy link
Collaborator

@a-rebets a-rebets left a comment

Choose a reason for hiding this comment

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

Solid change! Just needs some polish

fix: use hooks instead of atoms
@coderabbitai
Copy link

coderabbitai bot commented May 26, 2025

Walkthrough

This update introduces a persistent state mechanism for calendar visibility using Jotai atoms, including new types, atoms, and custom hooks. The calendar event data model is extended to include a calendarId field, and event filtering logic is updated to respect hidden calendars. Related UI components and API routes are modified to support and utilize these changes.

Changes

Files/Paths Change Summary
apps/web/src/atoms/calendars-visbility.ts, apps/web/src/atoms/README.md Added persistent atom for calendar visibility state and documentation for atom conventions.
apps/web/src/atoms/index.ts Exported new calendarsVisibilityAtom and its type.
apps/web/src/components/event-calendar/hooks/use-calendars-visibility.ts Added useCalendarsVisibility hook for accessing calendar visibility atom.
apps/web/src/components/event-calendar/hooks/index.ts Exported useCalendarsVisibility from hooks index.
apps/web/src/components/event-calendar/types.ts Added required calendarId property to CalendarEvent interface.
apps/web/src/components/event-calendar/utils/event.ts Added filterVisibleEvents utility to filter events by visible calendars.
apps/web/src/components/event-calendar/event-calendar.tsx Switched to using useViewPreferences and useCalendarsVisibility; filtered events based on visibility.
apps/web/src/components/calendar-view.tsx Included calendarId in transformed event objects.
apps/web/src/components/calendars.tsx Replaced static visibility indicator with interactive checkbox using useCalendarsVisibility for state.
apps/web/src/components/event-calendar/hooks/use-event-dialog.ts Added calendarId: "primary" to default event object in event dialog hook.
packages/api/src/routers/events.ts Added calendarId property to each event in API response for event fetching.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4cedc1f and 0d16e5c.

📒 Files selected for processing (6)
  • apps/web/src/atoms/calendars-visbility.ts (1 hunks)
  • apps/web/src/components/calendars.tsx (3 hunks)
  • apps/web/src/components/event-calendar/event-calendar.tsx (2 hunks)
  • apps/web/src/components/event-calendar/hooks/use-calendars-visibility.ts (1 hunks)
  • apps/web/src/components/event-calendar/utils/event.ts (1 hunks)
  • packages/api/src/routers/events.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • apps/web/src/components/event-calendar/utils/event.ts
  • packages/api/src/routers/events.ts
  • apps/web/src/components/event-calendar/hooks/use-calendars-visibility.ts
  • apps/web/src/components/event-calendar/event-calendar.tsx
  • apps/web/src/atoms/calendars-visbility.ts
  • apps/web/src/components/calendars.tsx

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
apps/web/src/atoms/calendars-visbility.ts (1)

1-11: ⚠️ Potential issue

Fix the filename typo.

The filename contains a typo: calendars-visbility.ts should be calendars-visibility.ts (missing 'i' in "visibility").

The implementation follows good patterns with Jotai's atomWithStorage and adheres to the agreed naming convention with the "analog-" prefix.

-// File: apps/web/src/atoms/calendars-visbility.ts
+// File: apps/web/src/atoms/calendars-visibility.ts

Make sure to update all imports of this file when renaming it.

♻️ Duplicate comments (1)
packages/api/src/routers/events.ts (1)

37-40: Formatting improvements enhance readability.

The multi-line formatting makes the code more readable and easier to follow, especially for complex operations like filtering, error handling, and chaining operations.

Note: This aligns with the previous reviewer's observation about formatting inconsistencies across the codebase.

Also applies to: 48-52, 55-58, 64-68, 136-140

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06be158 and 373acff.

📒 Files selected for processing (11)
  • apps/web/src/atoms/calendars-visbility.ts (1 hunks)
  • apps/web/src/atoms/index.ts (1 hunks)
  • apps/web/src/components/calendar-view.tsx (1 hunks)
  • apps/web/src/components/calendars.tsx (3 hunks)
  • apps/web/src/components/event-calendar/event-calendar.tsx (3 hunks)
  • apps/web/src/components/event-calendar/hooks/index.ts (1 hunks)
  • apps/web/src/components/event-calendar/hooks/use-calendars-visibility.ts (1 hunks)
  • apps/web/src/components/event-calendar/types.ts (1 hunks)
  • apps/web/src/components/event-calendar/utils/event.ts (12 hunks)
  • apps/web/src/components/ui/checkbox.tsx (1 hunks)
  • packages/api/src/routers/events.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
apps/web/src/components/event-calendar/hooks/use-calendars-visibility.ts (3)
apps/web/src/components/event-calendar/hooks/index.ts (1)
  • useCalendarsVisibility (18-18)
apps/web/src/atoms/index.ts (1)
  • calendarsVisibilityAtom (6-6)
apps/web/src/atoms/calendars-visbility.ts (1)
  • calendarsVisibilityAtom (7-10)
packages/api/src/routers/events.ts (1)
packages/api/src/providers/google-calendar.ts (1)
  • events (33-46)
apps/web/src/components/calendars.tsx (4)
apps/web/src/components/event-calendar/hooks/use-calendars-visibility.ts (1)
  • useCalendarsVisibility (4-6)
apps/web/src/components/ui/checkbox.tsx (1)
  • Checkbox (59-59)
apps/web/src/components/ui/sidebar.tsx (1)
  • SidebarMenuButton (715-715)
apps/web/src/components/ui/tooltip.tsx (2)
  • TooltipTrigger (60-60)
  • TooltipContent (60-60)
apps/web/src/components/event-calendar/utils/event.ts (1)
apps/web/src/components/event-calendar/types.ts (1)
  • CalendarEvent (3-13)
🔇 Additional comments (13)
apps/web/src/components/ui/checkbox.tsx (1)

17-17: LGTM! Clean syntax formatting.

Good cleanup removing the unnecessary trailing comma. This improves code consistency without affecting functionality.

apps/web/src/components/event-calendar/hooks/index.ts (1)

18-18: LGTM! Proper hook export organization.

Good addition following the existing pattern. The placement in the "Utility hooks" section is appropriate since this hook manages state utilities for calendar visibility.

apps/web/src/components/calendar-view.tsx (1)

85-85: LGTM! Calendar ID integration looks correct.

The addition of calendarId to the transformed event object properly supports the calendar visibility filtering feature. This change aligns perfectly with the updated CalendarEvent interface and enables downstream filtering logic.

apps/web/src/atoms/index.ts (1)

4-8: LGTM! Clean atom exports following established patterns.

The addition of calendarsVisibilityAtom and CalendarsVisibility type exports follows the same pattern as existing atoms and provides proper centralized access to the new calendar visibility state.

apps/web/src/components/event-calendar/hooks/use-calendars-visibility.ts (1)

1-6: LGTM! Excellent custom hook implementation.

This custom hook provides a clean abstraction over the Jotai atom, following React best practices. The wrapper pattern makes it easy for components to access calendar visibility state while maintaining flexibility for future implementation changes.

apps/web/src/components/event-calendar/utils/event.ts (2)

40-45: LGTM! Clean and efficient event filtering implementation.

The filterVisibleEvents function correctly filters out events from hidden calendars using a clear and efficient approach. The logic properly handles edge cases (empty hiddenCalendars array) and integrates well with the calendar visibility feature.


32-32: LGTM! Consistent formatting improvements.

The removal of trailing commas throughout the file improves code consistency and readability while maintaining the same functionality.

Also applies to: 49-49, 61-61, 78-78, 95-95, 106-106, 131-131, 160-160, 176-176, 191-192, 215-215, 225-225, 231-231, 238-238, 263-263, 266-266

packages/api/src/routers/events.ts (1)

53-53: Excellent addition of calendarId to event objects.

This change enables the frontend to filter events by calendar visibility, which is essential for the show/hide calendars feature. The spread operator correctly preserves all existing event properties while adding the calendar identifier.

apps/web/src/components/event-calendar/event-calendar.tsx (2)

21-21: Good adoption of custom hooks.

Replacing direct atom usage with useViewPreferences and useCalendarsVisibility hooks improves code organization and reusability. This addresses the previous review feedback about using hooks instead of direct atom access.


42-47: Well-structured filtering chain.

The filtering logic correctly chains filterPastEvents and filterVisibleEvents, applying both user preferences and calendar visibility state. The dependency array properly includes all relevant dependencies for the memoization.

apps/web/src/components/calendars.tsx (3)

39-50: Excellent use of useCallback for event handling.

The callback function is properly memoized and handles calendar visibility state correctly. The logic appropriately adds/removes calendar IDs from the hiddenCalendars array based on the checkbox state. This addresses the previous review feedback about extracting logic into useCallback.


82-95: Interactive checkboxes improve user experience.

The replacement of static checkmarks with interactive checkboxes enables users to toggle calendar visibility dynamically. The checked state correctly reflects whether a calendar is hidden (!hiddenCalendars.includes(item.id)), and the onCheckedChange handler properly updates the visibility state.


101-106: Nice tooltip enhancement.

The tooltip provides better user interaction feedback with appropriate styling and positioning. The bottom-aligned tooltip with start alignment works well for sidebar menu items.

Copy link
Collaborator

@a-rebets a-rebets left a comment

Choose a reason for hiding this comment

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

Cool! Thanks for updating, a few small things left

@a-rebets a-rebets added the bug Something isn't working label May 27, 2025
@iboughtbed iboughtbed force-pushed the feat/subcalendars branch from cfd534d to c1e2fb1 Compare May 27, 2025 13:55
Copy link
Collaborator

@a-rebets a-rebets left a comment

Choose a reason for hiding this comment

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

LGTM let's go

@a-rebets a-rebets requested a review from JeanMeijer May 27, 2025 15:09
@a-rebets
Copy link
Collaborator

@JeanMeijer this one is ready

@iboughtbed
Copy link
Collaborator Author

formatted, merged, resolved conflicts, ready to merge, @JeanMeijer

@JeanMeijer JeanMeijer merged commit 8142b7c into analogdotnow:main May 27, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants