Skip to content

Kingrayhan/socket#101

Merged
kingRayhan merged 2 commits intomainfrom
kingrayhan/socket
Apr 2, 2026
Merged

Kingrayhan/socket#101
kingRayhan merged 2 commits intomainfrom
kingrayhan/socket

Conversation

@kingRayhan
Copy link
Copy Markdown
Member

@kingRayhan kingRayhan commented Apr 2, 2026

Summary by CodeRabbit

  • Refactor
    • Unified real-time event name definitions across the notification and comment systems to improve consistency and maintainability.

…ling

- Refactored the listenChannel function to accept an object of event handlers instead of separate parameters, improving flexibility and readability.
- Updated the RealtimeProvider to use the new handler structure for invalidating notification queries upon receiving new notifications.
- Updated comment action and components to utilize REALTIME_PUSHER_EVENTS for event names, enhancing consistency across the codebase.
- Refactored the listenChannel function to improve event binding and unbinding logic, ensuring better maintainability.
- Adjusted notification handling in the RealtimeProvider to align with the new event structure.
@kingRayhan kingRayhan merged commit e0b57b1 into main Apr 2, 2026
1 check was pending
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f2ee3e53-ce93-4deb-9759-6334845f1cd1

📥 Commits

Reviewing files that changed from the base of the PR and between bec220f and 46fb559.

📒 Files selected for processing (7)
  • src/backend/services/comment.action.ts
  • src/components/comment-section.tsx
  • src/components/providers/RealtimeProvider.tsx
  • src/lib/inngest.ts
  • src/lib/pusher/pusher.client.ts
  • src/lib/pusher/pusher.server.ts
  • src/lib/pusher/realtime-events.ts

📝 Walkthrough

Walkthrough

A refactoring that centralizes hardcoded realtime event names into a single constants object (REALTIME_PUSHER_EVENTS) and simplifies the Pusher client API. The new event definitions module replaces string literals across backend services and React components, and the listenChannel signature shifts from accepting individual event strings to accepting a mapped handlers object.

Changes

Cohort / File(s) Summary
Event definitions and Pusher core
src/lib/pusher/realtime-events.ts, src/lib/pusher/pusher.server.ts, src/lib/pusher/pusher.client.ts
New event constants module exports REALTIME_PUSHER_EVENTS and types RealtimePusherEvent and RealtimeListenHandlers. Pusher modules re-export these, update publishMessage to accept RealtimePusherEvent instead of inline string union, and simplify listenChannel to accept handlers-mapped object instead of separate event and handler parameters.
Service and component integrations
src/backend/services/comment.action.ts, src/components/comment-section.tsx, src/components/providers/RealtimeProvider.tsx
Import and use new event constants to replace hardcoded event name strings in comment lifecycle and notification operations. RealtimeProvider additionally adapts to the new listenChannel API signature using event-to-handler mapping.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Constants bloom where strings once grew,
Event names now centralized and true,
From scattered literals, one home they've found—
TypeScript and harmony, tightly bound!
Real-time signals, organized with care. ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch kingrayhan/socket

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant