Skip to content

Refactor collection data fetching: consolidate logic into useCollection hook and simplify component code - #21

Merged
ebulgakov merged 2 commits into
mainfrom
refactor/collections-pages
Jul 31, 2026
Merged

Refactor collection data fetching: consolidate logic into useCollection hook and simplify component code#21
ebulgakov merged 2 commits into
mainfrom
refactor/collections-pages

Conversation

@ebulgakov

@ebulgakov ebulgakov commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • Improved collection detail and editing page loading.
    • Added clearer handling for missing collections and link-loading errors.
    • Enabled links to refresh independently without reloading collection details.
  • Refactor
    • Consolidated collection loading and authentication handling for more consistent behavior across collection pages.

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
linkfolio Ready Ready Preview Jul 31, 2026 1:30pm

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ebulgakov, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 500deaa8-c5a9-4fc8-b912-c35b2ab7887d

📥 Commits

Reviewing files that changed from the base of the PR and between 1b66182 and 62c5718.

📒 Files selected for processing (1)
  • app/shared/api/use-collection.ts
📝 Walkthrough

Walkthrough

The PR adds a shared useCollection composable for authenticated collection loading. The edit and collection pages use it. The collection page loads links separately and combines collection and link errors.

Changes

Collection loading

Layer / File(s) Summary
Shared collection loader
app/shared/api/use-collection.ts, app/shared/api/index.ts
useCollection resolves the session, fetches user-scoped collection data, exposes async state, derives 404 handling, and is exported from the API index.
Edit page integration
app/pages/collections/[id]/edit.vue
The edit page uses useCollection instead of managing session resolution, request caching, and 404 handling locally.
Collection page link loading
app/pages/collections/[id]/index.vue
The collection page loads links separately, combines collection and link errors, includes link failures in 404 handling, and refreshes only link data.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: consolidating collection data fetching in the useCollection hook and simplifying component code.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/collections-pages

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/shared/api/use-collection.ts (1)

6-10: 🚀 Performance & Scalability | 🔵 Trivial

Consider avoiding the duplicate session resolution.

The comment explains that useAuth().getSession() is re-called here because the auth middleware already resolves the session but does not expose it to the page. This means every navigation to a page using useCollection triggers 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

📥 Commits

Reviewing files that changed from the base of the PR and between ac2de9d and 1b66182.

📒 Files selected for processing (4)
  • app/pages/collections/[id]/edit.vue
  • app/pages/collections/[id]/index.vue
  • app/shared/api/index.ts
  • app/shared/api/use-collection.ts

Comment thread app/shared/api/use-collection.ts
@ebulgakov
ebulgakov merged commit d2353ed into main Jul 31, 2026
7 checks passed
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.

1 participant