feat: implement patch#36
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughIntroduces a comprehensive social posting feature spanning frontend UI, backend APIs, database schema, and cloud image storage. Adds post creation/deletion/listing, reaction tracking for posts and comments, and integrates a mixed-feed layout with optimistic updates and image upload support via Cloudinary. Changes
Sequence DiagramssequenceDiagram
actor User
participant WebUI as Web UI<br/>(CreatePostComposer)
participant API as API<br/>(post.create)
participant Cloudinary
participant Database as Database<br/>(Post, PostAttachment)
User->>WebUI: Enter body text & select image
User->>WebUI: Press Ctrl/⌘+Enter
WebUI->>WebUI: Convert image to base64
WebUI->>WebUI: Validate MIME type
WebUI->>API: POST /post.create<br/>(body, imageBase64, imageMimeType)
API->>Cloudinary: Upload image stream<br/>(with public_id path)
Cloudinary-->>API: Return secure_url & public_id
API->>Database: BEGIN TRANSACTION
API->>Database: INSERT Post<br/>(slug, body, imageUrl, userId)
API->>Database: INSERT PostAttachment<br/>(postId, imagePublicId)
API->>Database: UPDATE User<br/>INCREMENT totalPosts
API->>Database: COMMIT
Database-->>API: Success
API-->>WebUI: PostRow response
WebUI->>WebUI: Clear inputs
WebUI->>WebUI: Invalidate feed cache
WebUI-->>User: Refresh feed with new post
sequenceDiagram
actor User
participant WebUI as Web UI<br/>(PostReactionBar)
participant Cache as React Query<br/>Cache
participant API as API<br/>(reaction.set)
participant Database as Database<br/>(Reaction, counters)
User->>WebUI: Click/long-press reaction button
WebUI->>Cache: Capture snapshot<br/>(current state)
WebUI->>WebUI: Update local state<br/>(optimistic)
WebUI->>Cache: Update cached post<br/>(my reaction, totals)
WebUI-->>User: Immediate UI feedback
WebUI->>API: PUT /reaction.set<br/>(postId, type)
API->>Database: BEGIN TRANSACTION
API->>Database: Check existing reaction
alt Reaction exists & same type
API->>Database: DELETE reaction
API->>Database: DECREMENT totals
else New reaction
API->>Database: INSERT reaction
API->>Database: INCREMENT totals
else Different type
API->>Database: UPDATE reaction type
end
API->>Database: COMMIT
alt Server error
Database-->>API: Error
API-->>WebUI: Error response
WebUI->>Cache: Restore snapshot
WebUI-->>User: Revert UI
else Success
Database-->>API: Success
API-->>WebUI: Updated reaction type
WebUI->>Cache: Invalidate home feed
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
Summary by CodeRabbit