Skip to content

Use swr for data fetching#3438

Open
harryzcy wants to merge 28 commits into
mainfrom
swr
Open

Use swr for data fetching#3438
harryzcy wants to merge 28 commits into
mainfrom
swr

Conversation

@harryzcy

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings April 17, 2026 03:46
@harryzcy harryzcy added the chore Maintenance label Apr 17, 2026
@codecov

codecov Bot commented Apr 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.65%. Comparing base (5ff369d) to head (0ad5316).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3438   +/-   ##
=======================================
  Coverage   29.65%   29.65%           
=======================================
  Files          19       19           
  Lines         725      725           
  Branches      101      101           
=======================================
  Hits          215      215           
  Misses        459      459           
  Partials       51       51           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces SWR as a dependency and adds a new SWR-based hook for fetching the emails list, aligning the web client’s data fetching with a cache/revalidation pattern.

Changes:

  • Added swr to the web app dependencies.
  • Refactored email list query param building into a shared helper.
  • Introduced useEmails (SWR-powered) alongside the existing listEmails fetch function.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
web/src/services/emails.ts Adds SWR hook for listing emails and factors query param generation into a helper.
web/package.json Adds swr dependency.
web/package-lock.json Locks SWR and related transitive dependencies.
Files not reviewed (1)
  • web/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web/src/services/emails.ts Outdated
Comment thread web/src/services/emails.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces SWR as a dependency and begins adding an SWR-based hook for fetching paginated email lists, alongside a small refactor in the email root page’s state initialization.

Changes:

  • Added swr to web dependencies (and lockfile updates).
  • Refactored listEmails to use a shared query-param builder and introduced a new useEmails SWR hook wrapper.
  • Minor reordering of year/month state initialization in EmailRoot.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
web/src/services/emails.ts Adds SWR hook (useEmails) and refactors query param construction for listEmails.
web/src/pages/EmailRoot.tsx Moves year/month initialization earlier in the component.
web/package.json Adds swr dependency.
web/package-lock.json Locks swr and related dependency graph changes.
Files not reviewed (1)
  • web/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

web/src/services/emails.ts:95

  • Because listEmails always calls response.json() without checking response.ok, HTTP 4xx/5xx responses won’t be surfaced as SWR error (and may fail later with a shape mismatch). Consider throwing on non-OK responses (and/or returning a typed error payload) so useEmails can reliably enter the 'error' loadingState.
  const params = generateListEmailsParamString(props)
  const response = await fetch('/web/emails?' + params, {
    method: 'GET'
  })
  return response.json() as Promise<ListEmailsResponse>
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web/src/services/emails.ts Outdated
Comment thread web/src/services/emails.ts Outdated
Comment thread web/src/services/emails.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants