feature: port item details, recursive comments and polls to React (Phase 2c) - #574
Open
vibhaseshadri-cognition wants to merge 1 commit into
Conversation
…t (Phase 2c) Co-Authored-By: Vibha Seshadri <vibha.seshadri@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Phase 2c of the Angular → React migration: ports
ItemDetailsComponentand the recursiveCommentComponentintoweb/. Angular sources insrc/are untouched; this only fills in theItemDetailsPageplaceholder and addsweb/src/item-details/**.pages/ItemDetailsPage.tsx—useParams().id→fetchItemContent(Number(id)),<Loader />while pending,<ErrorMessage message="Could not load item comments." />on rejection,window.scrollTo(0, 0)on mount, both header variants (.mobile.item-header/.laptop), poll bars,.subjectviadangerouslySetInnerHTML, back button viauseNavigate()(-1)(AngularLocation.back()), and the comment list. The effect is keyed onidwith acancelledflag so a late response for a previous id can't overwrite state.item-details/Comment.tsx— recursion overcomment.comments,useStatecollapse per comment rendering[-]/[+]and toggling.meta-collapseplus thehiddenattribute (same as Angular's[hidden], so children stay mounted),deletedbranch rendering[deleted] | Comment Deleted.routerLinkActive="active"is preserved by usingNavLink(react-router v6 appendsactiveto a stringclassName).Two things worth flagging in the SCSS port, since it's not byte-for-byte verbatim:
p,a,ul,li) fromitem-details.component.scssare nested under.item, andcomment.component.scss's:host >>> abecomes.comment-list a..main-contentstays top-level (identical to the rule the feed component already declares). Rendered results are unchanged; nothing leaks into other pages.[class.head-margin]="item.text"is keyed onitem.contenthere.Storyhas notextfield (and the node-hnapi item payload returnscontent), so the Angular condition was dead at runtime;contentis the field the template meant. Net effect: text posts get the intended 15px header margin.Tests: 18 new Vitest/RTL cases (
ItemDetailsPage.test.tsx,Comment.test.tsx) covering loading/error, both header variants,openLinkInNewTabtarget/rel, self-linking titles, job postings, poll bar widths (30/40 → 75%), nested comments, independent collapse of parent vs. child, deleted comments, back navigation and refetch on id change.npm run lint,npm test(45 passed) andnpm run buildall pass inweb/.Link to Devin session: https://app.devin.ai/sessions/c6d479ade59146b0a3279b219add9b40
Requested by: @vibhaseshadri-cognition
Devin Review