Skip to content

feature: PR 2/8 — models, Promise-based HN API and comment util - #699

Open
devin-ai-integration[bot] wants to merge 2 commits into
devin/react-migration-01-scaffoldingfrom
devin/react-migration-02-models-api
Open

feature: PR 2/8 — models, Promise-based HN API and comment util#699
devin-ai-integration[bot] wants to merge 2 commits into
devin/react-migration-01-scaffoldingfrom
devin/react-migration-02-models-api

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 26, 2026

Copy link
Copy Markdown

Summary

PR 2 of 8 (stacked on #698). Framework-agnostic foundations under src/react/; nothing under src/app/ is touched.

  • src/react/models/* — the six Angular models ported verbatim (hence strictPropertyInitialization: false in the React tsconfig, since the originals are classes with uninitialized fields).
  • src/react/utils/comments.tsformatComments(count) replaces CommentPipe, same output (discuss / 1 comment / N comments).
  • src/react/api/hackernews.ts — replaces HackerNewsAPIService: RxJS Observable + unfetch become platform fetch + Promises.

Two deliberate deviations from the Angular service:

  1. HTTP errors now reject. The old lazyFetch resolved on any response, so a 500 surfaced as a JSON parse failure or an empty feed; the shared getJson helper throws on !res.ok so Feed/ItemDetails can render ErrorMessage.
  2. fetchItemContent awaits the poll fetches instead of returning early:
if (story.type === 'poll') {
    story.poll_votes_count = 0;
    const results = await Promise.all(story.poll.map((_, i) => fetchPollContent(story.id + i + 1)));
    results.forEach((r, i) => { story.poll[i] = r; story.poll_votes_count += r.points; });
}
return story; // poll + poll_votes_count fully populated

The Angular version returned the story while subscribe callbacks mutated poll afterwards — fine with Angular change detection, unreliable with React state.

Also note FeedType ('poll' | 'story' | 'job') is the item type, not the route name, so feed names get their own FeedName type used by fetchFeed and, later, the routes.

Verified: npm run typecheck:react, npx vite build, plus a live fetchFeed('news', 1) call returning 30 stories.

Devin-Org: engineering

Link to Devin session: https://app.devin.ai/sessions/e6419ebe67ff4f749fe1573a8e26cd07
Requested by: @abboudp


Note

Devin errored when opening this Pull Request as abboudp.
As a fallback, Devin opened this PR as itself.


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Devin Review (Staging)

devin-ai-integration Bot and others added 2 commits August 26, 2026 13:38
Co-Authored-By: Paul Abboud <abboudpaul112@gmail.com>
Co-Authored-By: Paul Abboud <abboudpaul112@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants