Phase 2: Core Infrastructure Migration - Settings Context & API Service#153
Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Open
Phase 2: Core Infrastructure Migration - Settings Context & API Service#153devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
Conversation
…and React Router - Create SettingsContext with theme management, localStorage persistence, and media query listener - Add useSettings() custom hook for accessing settings context - Create API hooks (useFeed, useItemDetails, useUser) for Hacker News data fetching - Set up React Router v6 with all routes and lazy loading for ItemDetails and User - Add placeholder Feed, ItemDetails, and User components for routing Co-Authored-By: Jack Meigel <jack.meigel@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:
|
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.
Phase 2: Core Infrastructure Migration - Settings Context & API Service
Summary
This PR implements Phase 2 of the Angular to React migration, adding the core infrastructure components that will be used throughout the React application. Building on the Phase 1 foundation (project setup, type definitions, utility functions), this phase migrates the Angular services to React patterns.
Key changes:
The SettingsContext (
src/contexts/SettingsContext.tsx) provides theme management with three options (default, night, amoledblack), localStorage persistence for all settings, and a media query listener forprefers-color-scheme: darkthat automatically sets the theme when no saved preference exists.The API hooks (
src/hooks/useHackerNewsAPI.ts) replace the Angular RxJS-based HackerNewsAPIService with React hooks:useFeedfor paginated story lists,useItemDetailsfor individual items with poll support, anduseUserfor user profiles. All hooks include loading/error states and request cancellation.React Router v6 is configured in
App.tsxwith routes matching the Angular app structure. ItemDetails and User components are lazy-loaded usingReact.lazy()to match the Angular lazy loading pattern.Review & Testing Checklist for Human
useFeed,useItemDetails, anduseUsersuccessfully fetch data fromhttps://node-hnapi.herokuapp.comuser.aboutwith dangerouslySetInnerHTML - verify this is acceptable given the API sourceRecommended test plan:
cd react-app && npm install && npm run dev/news/1and verify stories load/item/:idroute and lazy loading/user/:idto test user profile loadingNotes
This PR includes the Phase 1 foundation work (models, utils, project setup) as it builds on that branch. The Feed, ItemDetails, and User components are intentionally minimal placeholders - full UI implementation is planned for Phase 3.
Link to Devin run: https://app.devin.ai/sessions/1c95de9914fa4b998b4f736184b1ed5c
Requested by: Jack Meigel (@cogjack)