Surface feed post Edit in header and fix community edit/save behavior#23
Surface feed post Edit in header and fix community edit/save behavior#23ukuku360 wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c8c739131
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const viewerLabel = viewer.label.trim().toLowerCase() | ||
| const ownerLabel = (ownerAuthor ?? '').trim().toLowerCase() | ||
| if (!viewerLabel || !ownerLabel) return false | ||
|
|
||
| return viewerLabel === ownerLabel |
There was a problem hiding this comment.
Restrict fallback ownership check to missing user IDs
This fallback returns true whenever display names match, even after a user-id mismatch, so two accounts with the same nickname will both be treated as owners and see the new Edit controls for each other’s feed posts/comments. Because the edit flows call update mutations once this guard passes, this broadens edit eligibility beyond actual ownership; the fallback should only run when ownerUserId is absent.
Useful? React with 👍 / 👎.
| e.preventDefault() | ||
| if (normalizedEditContent.length === 0 || normalizedEditContent === comment.content) return | ||
|
|
||
| await editCommentMutation.mutateAsync({ commentId: comment.id, text: normalizedEditContent }) |
There was a problem hiding this comment.
Catch comment edit mutation failures before returning
mutateAsync rejects on failure even when onError runs, and this submit handler does not catch that rejection; since the form calls it via void handleEditSubmit(...), failed saves (for example RLS/network errors) produce unhandled promise rejections in the browser. Wrap this await in try/catch (or use mutate) so edit failures stay fully handled by component state.
Useful? React with 👍 / 👎.
|
|
||
| try { | ||
| setIsEditPending(true) | ||
| await onEdit(post.id, normalizedEditContent) |
There was a problem hiding this comment.
Handle post edit mutation rejections in submit path
If onEdit fails, this await rejects and bubbles out of the async form submit handler because there is no catch, leaving an unhandled rejection despite CommunityFeed already setting a user-facing error state in onError. Catching the rejection locally avoids noisy runtime errors and keeps the edit UX failure path controlled.
Useful? React with 👍 / 👎.
Motivation
Editaction from the crowded action stack into the post header/status cluster so it's easier to find and use.Description
rk-post-quick-editstyles for consistent header action visuals and disabled/loading feedback (apps/web/src/features/feed/pages/FeedPage.tsx,apps/web/src/app/styles.css).isSameAuthorByFallbackhelper andeditFeedPost/editFeedCommentflows to support inline header editing for feed posts and prompt-based edits for feed comments, including per-item pending state tracking (isPostEditPendingByPostId,isCommentEditPendingByCommentId) (FeedPage.tsx).CommunityPostCardandCommunityCommentSection, and wiredonEditthroughCommunityFeed(CommunityPostCard.tsx,CommunityCommentSection.tsx,CommunityFeed.tsx).editsuccess (contentandupdated_at) then awaiting query invalidation, and addedhandleEditwrapper that calls the mutation (CommunityFeed.tsx).updateCommunityPostandupdateCommentservice functions, and addedupdateComment/updateCommunityPostandupdatePosthelpers where needed (apps/web/src/services/community/community.service.ts,apps/web/src/services/comments/comments.service.ts,apps/web/src/services/posts/posts.service.ts).updated_attoCommunityPostandCommunityCommenttypes and extendedsupabase_schema.sqlto addupdated_at, update policies/triggers, and keep DB schema compatible with edit flows (apps/web/src/types/domain.ts,supabase_schema.sql).Testing
cd apps/web && npm run typecheckand it succeeded.cd apps/web && npm run lintand it succeeded.Codex Task