Skip to content

refactor(post-card): split the 1104-line card into engagement hook, action bar and author line - #386

Merged
PastaPastaPasta merged 2 commits into
stagingfrom
refactor/post-card-split
Sep 8, 2026
Merged

refactor(post-card): split the 1104-line card into engagement hook, action bar and author line#386
PastaPastaPasta merged 2 commits into
stagingfrom
refactor/post-card-split

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

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 one ActionTooltip; every data-testid is preserved.
  • components/post/post-author-line.tsx: display name, verified mark, and handle-or-identity (with resolveUsernameState / hasRealProfile moved here as exports).
  • The identity-id copy and share buttons go through useCopy, so they only toast success on success.

Behaviour preserved: every guard (repostable, bookmarkable, hideAvatar opening 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 build all green locally
  • CI
  • Manual: like/unlike, repost/undo, quote, bookmark, reply (incl. a private post you cannot reply to), tip, share, follow/block from the more menu, delete own post, click-through to detail, a reposted card, a tip card, a deleted card

🤖 Generated with Claude Code

…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.
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: d752f39f-d286-4808-8b32-736300e7aebe

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

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

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.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying yappr-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: b8ecdfe
Status:⚡️  Build in progress...

View logs

@PastaPastaPasta
PastaPastaPasta merged commit d95b448 into staging Sep 8, 2026
8 of 9 checks passed
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