feat: migrate ItemDetails and Comment components from Angular to React + TypeScript#249
Open
devin-ai-integration[bot] wants to merge 4 commits into
Open
Conversation
…t + TypeScript - Convert ItemDetailsComponent to React functional component (ItemDetails.tsx) - Convert CommentComponent to React functional component (Comment.tsx) - Replace Angular DI with useParams, useNavigate, useSettings hooks - Replace comment pipe with formatCommentCount utility function - Convert SCSS to CSS Modules (camelCase class names) - Preserve all behavior: loading, error, scroll-to-top, back nav, polls, recursive comments - Original Angular files kept alongside for comparison Co-Authored-By: Charity Quinn <charity.quinn@cognition.ai>
Author
🤖 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:
|
Adds .catch() to Promise.all(pollPromises) to handle network errors and AbortError on unmount, preventing unhandled promise rejections and perpetual loading spinners. Co-Authored-By: Charity Quinn <charity.quinn@cognition.ai>
- Nest bare p/a selectors inside .item in ItemDetails.module.scss - Wrap bare a selector in .commentWrapper in Comment.module.scss - Add commentWrapper class to Comment.tsx root div - Guard poll bar width calculation against division by zero Co-Authored-By: Charity Quinn <charity.quinn@cognition.ai>
Co-Authored-By: Charity Quinn <charity.quinn@cognition.ai>
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
Migrates the
item-detailsAngular module (ItemDetailsComponent + CommentComponent) to React functional components with TypeScript, following the Angular → React mapping rules specified in the task.5 new files created (original Angular files preserved alongside):
src/app/item-details/ItemDetails.tsxitem-details.component.ts+.htmlsrc/app/item-details/ItemDetails.module.scsssrc/app/item-details/comment/Comment.tsxcomment.component.ts+.htmlsrc/app/item-details/comment/Comment.module.scsssrc/app/shared/utils/formatCommentCount.tscommentpipeKey conversions applied:
@Component+ template → functional component with inline JSXngOnInit+route.params.subscribe()→useEffect+useParams()(react-router-dom v6)HackerNewsAPIService(DI) → plainfetchwithuseEffect+useState+AbortControllercleanupSettingsService(DI) →useSettings()hook (React Context)_location.back()→useNavigate()→navigate(-1)*ngIf/*ngFor→ conditional&&/.map()[innerHTML]→dangerouslySetInnerHTML[ngStyle]→ inlinestyleobject[class.X]="cond"→ template literal class concatenation[routerLink]→<Link to="...">@Input()→ typedPropsinterfacecommentpipe →formatCommentCount()utilitySubscription→AbortControllercleanup inuseEffectstyleUrls→ CSS Modules (.module.scss)(click)→onClickAll existing behavior preserved: loading state, error state, scroll-to-top, back navigation, poll rendering with vote bars, recursive comment tree with collapse/expand, conditional link targets (
_blank), deleted comment handling.Review & Testing Checklist for Human
ItemDetails.tsxcorrectly fetches and displays story content including title, points, user, time_ago, domain, and commentsCommentcomponent handles deeply nested comment trees and collapse/expand toggleformatCommentCountreturns "discuss" for 0, "1 comment" for 1, and "N comments" for N > 1Recommended test plan:
ItemDetailsas a route at/item/:idSettingsContextwithuseSettings()hook, and stubLoader/ErrorMessagecomponents/item/<valid-hn-item-id>and verify full renderingNotes
useSettings,Loader, andErrorMessageimports — these would need to be created as part of the broader migration effort (they are the React equivalents of the existing Angular shared components)StoryandCommentmodels are imported from the existing shared models (Angular classes), which should be converted to TS interfaces as part of the full migrationLink to Devin session: https://app.devin.ai/sessions/e966af3e2bda440d801d01a782a95eca
Requested by: @charityquinn-cognition
Devin Review