Skip to content

Batch 5: MLB API abstraction layer and single-pass box score render#31

Open
tinkerwise wants to merge 1 commit into
mainfrom
feature/batch-5-api-abstraction
Open

Batch 5: MLB API abstraction layer and single-pass box score render#31
tinkerwise wants to merge 1 commit into
mainfrom
feature/batch-5-api-abstraction

Conversation

@tinkerwise

Copy link
Copy Markdown
Owner

Closes #26

Summary

  • New src/scripts/mlbApi.js centralizes all MLB Stats API URL construction and fetching in named async functions
  • scores.js and sidebars.js refactored to import from mlbApi.js — no more inline URL strings
  • Box score popover now shows a loading skeleton, awaits all async fetches via Promise.allSettled, then renders exactly once — eliminating the visible re-render flash

Files changed

  • src/scripts/mlbApi.js — new file, 10+ named API functions
  • src/scripts/scores.js — imports from mlbApi.js, showBoxScore() made async with single-pass render
  • src/scripts/sidebars.js — imports from mlbApi.js, direct fetch calls removed

Test plan

  • Scores bar loads and displays games correctly
  • Click a score chip — box score opens with a brief "Loading…" state then renders complete (no flash)
  • Roster, transactions, IL, standings, leaders all load normally
  • On Deck shows next Orioles game
  • No broken fetch calls in Network tab (all URLs should match previous behavior)

Generated by Claude Code

- Add src/scripts/mlbApi.js centralizing all MLB Stats API fetch() calls
- Refactor scores.js and sidebars.js to import from mlbApi.js instead
  of constructing URLs inline; all endpoint logic now lives in one place
- Fix box score popover flash: show loading skeleton, await all pending
  fetches with Promise.allSettled, then render the complete popover once

https://claude.ai/code/session_01C1vhzbYUCRYNikqatrcAYN
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.

MLB API abstraction layer and single-pass box score render

2 participants