Refactor collection data fetching: consolidate logic into useCollection hook and simplify component code - #21
Conversation
…on hook and simplify component code
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 37 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR adds a shared ChangesCollection loading
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/shared/api/use-collection.ts (1)
6-10: 🚀 Performance & Scalability | 🔵 TrivialConsider avoiding the duplicate session resolution.
The comment explains that
useAuth().getSession()is re-called here because theauthmiddleware already resolves the session but does not expose it to the page. This means every navigation to a page usinguseCollectiontriggers the session check twice (once in middleware, once here), each potentially a network round trip. Passing the middleware-resolved session forward (for example through a shared request-scoped state) would avoid the duplicate call.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/shared/api/use-collection.ts` around lines 6 - 10, Update the useCollection session flow around useAuth().getSession() to reuse the session resolved by the auth middleware through shared request-scoped state instead of performing a second resolution. Ensure the middleware stores or exposes the resolved session and preserve the existing per-user cache-key behavior on both SSR and client navigation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/shared/api/use-collection.ts`:
- Around line 10-19: Enable Nuxt’s experimental async context support by adding
experimental.asyncContext: true in nuxt.config.ts, preserving the existing
useCollection flow through useAuth().getSession(), useRequestFetch(), and
useAsyncData().
---
Nitpick comments:
In `@app/shared/api/use-collection.ts`:
- Around line 6-10: Update the useCollection session flow around
useAuth().getSession() to reuse the session resolved by the auth middleware
through shared request-scoped state instead of performing a second resolution.
Ensure the middleware stores or exposes the resolved session and preserve the
existing per-user cache-key behavior on both SSR and client navigation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b6e317ea-406e-46d7-95a2-3487bfb01cc5
📒 Files selected for processing (4)
app/pages/collections/[id]/edit.vueapp/pages/collections/[id]/index.vueapp/shared/api/index.tsapp/shared/api/use-collection.ts
…proper context handling in async setup
Summary by CodeRabbit