Skip to content

Conversation

@sidneyswift
Copy link
Collaborator

@sidneyswift sidneyswift commented Jan 16, 2026

  • Fix queryKey mismatch in useCreateOrganization (userOrganizations → accountOrganizations)
  • Add cache invalidation in useOrgSettings after saving org image/name
  • Persist fresh artist data to localStorage in useInitialArtists

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Organization list now refreshes correctly after creating or updating organizations.
    • Selected artist preference is persisted reliably across sessions and avoids unnecessary updates.
    • Changes in organization settings are now reflected consistently throughout the app.

✏️ Tip: You can customize this high-level summary in your review settings.

- Fix queryKey mismatch in useCreateOrganization (userOrganizations → accountOrganizations)
- Add cache invalidation in useOrgSettings after saving org image/name
- Persist fresh artist data to localStorage in useInitialArtists
@vercel
Copy link

vercel bot commented Jan 16, 2026

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

Project Deployment Review Updated (UTC)
recoup-chat Ready Ready Preview Jan 16, 2026 10:34pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

Cache invalidation key changed from "userOrganizations" to "accountOrganizations" in organization-related hooks; artist selection persistence now saves refreshed or manually selected artists to localStorage and avoids redundant state updates.

Changes

Cohort / File(s) Summary
Organization cache updates
hooks/useCreateOrganization.ts, hooks/useOrgSettings.ts
Replaced invalidation/refresh key "userOrganizations""accountOrganizations"; useOrgSettings now obtains queryClient and calls queryClient.invalidateQueries('accountOrganizations') after save.
Artist selection persistence & sync
hooks/useInitialArtists.tsx
Restore effect only updates selectedArtist when different; refresh effect persists refreshed artist via saveSelection(currentArtist); manual selection now calls saveSelection(artist); dependency arrays updated.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client as Client (UI / Hook)
participant API as API Server
participant QC as QueryClient (cache)
participant DB as LocalStorage
rect rgba(100,150,240,0.5)
Client->>API: POST /organizations (create)
API-->>Client: 201 Created (org)
Client->>QC: invalidateQueries('accountOrganizations')
QC-->>Client: refetch accountOrganizations
end

mermaid
sequenceDiagram
participant Hook as useInitialArtists Hook
participant QC as QueryClient (list)
participant DB as LocalStorage
rect rgba(120,200,100,0.5)
Hook->>QC: fetch artists list
QC-->>Hook: artists list
Hook->>Hook: compare saved selection vs current
alt different or refreshed
Hook->>DB: saveSelection(currentArtist)
end
end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • sweetmantech

Poem

🎶 Keys changed, selections kept in store,

accountOrganizations knocks on the door.
Artists remembered, no needless reset,
LocalStorage hums — the state is set. ✨

🚥 Pre-merge checks | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Solid & Clean Code ⚠️ Warning Pull request violates DRY and SRP principles with duplicated magic string and multi-concern hook responsibilities. Extract query key to lib/consts.ts and refactor useInitialArtists.tsx by creating separate usePersistArtistSelection() hook to isolate concerns.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@hooks/useInitialArtists.tsx`:
- Around line 44-50: The restore effect is causing redundant state-update cycles
because it sets selectedArtist when selections changes even if the referenced
artist is the same; update the restore effect in useInitialArtists (the effect
that reads from selections and calls setSelectedArtist) to compare
selectedArtist?.account_id (or the current selected's account_id) with the
candidate artist.account_id from selections and only call setSelectedArtist and
saveSelection when the account_id differs, ensuring you still handle the
currentArtist flow but avoid resetting state to a new object reference that
represents the same account.

Compare account_id before calling setSelectedArtist to avoid unnecessary
re-render cycles when selections changes but artist is already selected
@sidneyswift sidneyswift merged commit e437ccd into main Jan 17, 2026
5 of 6 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.

2 participants