refactor(post-card): split the 1104-line card into engagement hook, action bar and author line - #386
Merged
Merged
Conversation
…ction bar and author line components/post/post-card.tsx held three copies of the optimistic like/repost/bookmark flip with rollback, six hand-rolled tooltips in the action row, and the author-name state machine. It is 469 lines now: hooks/use-post-engagement.ts owns the three toggles and their unconfirmed-reference gate, components/post/post-action-bar.tsx is the reply/repost/like/tip/bookmark/share row, and post-author-line.tsx is the name, verified mark and handle-or-identity display. The share and identity copy buttons go through useCopy. Behaviour kept: the same guards on each toggle, the topology rules for reposting and bookmarking replies, the tombstone and sensitive gates, the pending-navigation handoff to the detail page, every data-testid.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
2 tasks
The tip badge gets back the mb-2 and cursor-help it lost. Single-handler action-bar props flatten to onQuote/onTip/onShare; the engagement hook takes the target kind and derives repostable/bookmarkable itself; reportSpendError leaves the hook body; stats carries views so the navigation payload is one expression; hasProfile is derived inside the author line; one stopPropagation helper replaces four inline copies and stopAndRun covers the more-menu items too. The card's menu constant is named apart from the action bar's, which differs on purpose.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
components/post/post-card.tsx(1104 lines) is now 469 lines that resolve display values and compose:hooks/use-post-engagement.ts: like / repost / bookmark state with the optimistic flip, rollback, the shared unconfirmed-reference gate, and the frozen-balance vs buy-YAPP error split. Three near-identical handlers become one hook.components/post/post-action-bar.tsx: the reply / repost+quote menu / like / tip / bookmark / share row. Six hand-rolled tooltip blocks become oneActionTooltip; everydata-testidis preserved.components/post/post-author-line.tsx: display name, verified mark, and handle-or-identity (withresolveUsernameState/hasRealProfilemoved here as exports).useCopy, so they only toast success on success.Behaviour preserved: every guard (
repostable,bookmarkable,hideAvataropening the likes modal, private-reply gating), tombstone and sensitive gates over the whole content region, the pending-navigation handoff, the more-menu items, the reply-context embed.Part of the anti-slop cleanup series (after #370–#385). This was the last of the three god-file splits.
Test plan
npm run lint(zero warnings),tsc --noEmit,npm run test,npx knip,npm run buildall green locally🤖 Generated with Claude Code