feat: Add React Query hooks for HackerNews API migration (Phase 1)#167
Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Open
feat: Add React Query hooks for HackerNews API migration (Phase 1)#167devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Conversation
Create src/hooks/ with custom React hooks replacing Angular HackerNewsAPIService: - useFeed(feedType, page): fetches feed listings - useItem(id): fetches item with poll aggregation logic - useUser(id): fetches user profiles - usePollResults(id): fetches individual poll results - TypeScript interfaces for Story, User, PollResult, Comment, FeedType Co-Authored-By: Eashan Sinha <eashan.sinha@codeium.com>
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:
|
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.
feat: Add React Query hooks for HackerNews API (Phase 1)
Summary
Converts the Angular
HackerNewsAPIServiceto custom React hooks using TanStack Query (@tanstack/react-query) as part of the Angular-to-React migration. This is Phase 1 — hooks only, no wiring to components yet.New files (all under
src/hooks/):types.ts— TypeScript interfaces mirroring the existing Angular models (Story,User,PollResult,Comment,FeedType)useFeed.ts— fetches feed listings by type and pageuseItem.ts— fetches an item; includes poll aggregation logic (fetches poll options viaPromise.alland sumspoll_votes_count)useUser.ts— fetches user profilesusePollResults.ts— fetches individual poll result itemsindex.ts— barrel exportRxJS Observables and
lazyFetchare replaced withasync/await+ React Query'suseQuery. Poll logic from the Angular service is preserved: for poll-type stories, poll options are fetched in parallel usingstory.id + ifori in 1..poll.length.Review & Testing Checklist for Human
@tanstack/react-queryis NOT installed —package.jsonwas not modified. Confirm this is acceptable for Phase 1, or whether the dependency should be added now so the files at least compileuseItem.ts(lines 26-27): verifystory.id + ifori in 1..numberOfPollOptionsmatches the original Angular behavior and API expectationsBASE_URLis hardcoded in each hook file — decide if this should be extracted to a shared constant before later phases build on top of thisNotes
crated_timetypo in theUserinterface is intentionally preserved from the original Angular model (src/app/shared/models/user.ts)Story.time_agois typednumber(matching the original Angular class) whileComment.time_agoisstring— this discrepancy exists in the original codebaseRequested by: @eashansinha
Link to Devin run: https://app.devin.ai/sessions/a63f2fb87f504e82991177c18bdcadc8