PR 3/10 — Port Hacker News data layer to fetch + useFetch hook - #755
Open
devanshi-gpta wants to merge 1 commit into
Conversation
Co-Authored-By: Devanshi Gupta <devanshi.gupta@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
Part of the Angular -> React migration chain; based on
devin-09.08.2026-devanshi/port-models-and-shared-styles.Ports
src/app/shared/services/hackernews-api.service.tsandsrc/app/shared/pipes/comment.pipe.tsintoreact-app/, dropping RxJS entirely:src/services/hackernews-api.ts—fetchFeed,fetchItemContent,fetchPollContent,fetchUseras plainasyncfunctions overfetch, each taking an optionalAbortSignaland throwing on non-ok responses (the AngularlazyFetchObservable wrapper silently ignored HTTP errors).poll/poll_votes_countlater viasubscribe, so consumers saw a partially populated story. The port awaits the per-option requests in parallel, so the resolved story is already complete:src/hooks/useFetch.ts—useFetch<T>(fetcher, deps)returning{ data, error, loading }; aborts the in-flight request on deps change/unmount and swallowsAbortError. Will back the feed, item-details and user pages.src/utils/format-comment-count.ts—formatCommentCount(count)replacingCommentPipe('discuss'/'1 comment'/'N comments').Proposed fixes
formatCommentCountand, with a stubbedglobalThis.fetch, for poll aggregation, the non-poll path, non-ok rejection and signal pass-through.npm run typecheck,npm run lint,npm testandnpm run buildpass inreact-app/.src/(the Angular app) are touched.Link to Devin session: https://app.devin.ai/sessions/50f5f5797eb8469d9e8e0eaab2586019
Open in Devin Desktop: https://app.devin.ai/desktop/session/50f5f5797eb8469d9e8e0eaab2586019?variant=devin
Requested by: @devanshi-gpta