-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(web): avoid redundant queries for unchanged comment values #1317
Conversation
WalkthroughThe changes involve modifications to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for reearth-cms ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
web/src/components/molecules/Common/CommentsPanel/Comment.tsx (1)
47-56
: Consider enhancing error handlingThe current error handling only logs to console, which might not be sufficient for production. Consider adding user feedback for failed comment updates.
const handleSubmit = useCallback(async () => { try { if (comment.content !== value) { await onCommentUpdate?.(comment.id, value); } } catch (info) { - console.log("Validate Failed:", info); + console.error("Comment update failed:", info); + // Consider adding a notification system + notification.error({ + message: "Failed to update comment", + description: "Please try again later" + }); } finally { setShowEditor(false); } }, [comment.content, comment.id, value, onCommentUpdate]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
web/src/components/molecules/Common/CommentsPanel/Comment.tsx
(1 hunks)web/src/components/molecules/Request/Details/Comment.tsx
(1 hunks)
🔇 Additional comments (4)
web/src/components/molecules/Common/CommentsPanel/Comment.tsx (2)
48-50
: LGTM! Optimization prevents unnecessary comment updates
The conditional check effectively prevents unnecessary API calls when the comment content hasn't changed, aligning with the PR's objective to optimize performance.
56-56
: LGTM! Correct dependency array update
The addition of comment.content
to the dependency array is necessary as it's used within the handleSubmit
callback.
web/src/components/molecules/Request/Details/Comment.tsx (2)
46-48
: LGTM! Optimization prevents unnecessary API calls
The added condition effectively prevents redundant comment updates when the content hasn't changed, aligning with the PR's objective.
Consider adding a debug log when skipping the update to help with troubleshooting.
54-54
: LGTM! Proper dependency management
The dependency array correctly includes comment.content
which is required for the comparison logic in the callback.
Overview
This PR fixes to not throw a query if the new comment value is the same as before.
Summary by CodeRabbit
New Features
Bug Fixes