refactor(groups): split useUserGroups' {all} boolean into two queries - #515
Merged
Merged
Conversation
…odules
fetchUserGroups(userId, { all }) flipped both the auth model (admin-gated)
and the is_member semantics behind one flag. Splits it into
useMyGroupsQuery (always member-scoped, is_member always true) and
useAllGroupsQuery (admin view, falling back to the member-only result for
non-admins). The Groups page's My/All toggle now renders one of two
sibling components instead of threading the boolean into a shared hook.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015AWdzYUiNjQwtASYbWTnaX
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Regular admins are shown the all-groups view but are treated as non-admins by the new query.
Review effort: Balanced
Findings: 1
What changed in this PR
Splits group fetching into member-scoped and administrative queries, updating consumers, cache invalidation, and integration coverage.
Changes:
- Adds
useMyGroupsQueryanduseAllGroupsQuery. - Migrates group consumers and query keys.
- Adds Supabase integration fixtures and tests.
| File | Description |
|---|---|
src/test/integration/fixtures/groups.ts |
Adds group fixtures. |
src/test/integration/fixtures/adminRoles.ts |
Supports configurable admin roles. |
src/routes/groups/index.tsx |
Selects the appropriate group query. |
src/routes/__root.tsx |
Prefetches member groups. |
src/pages/Settings/SettingsPage.tsx |
Uses the member query. |
src/pages/SetDetails/SetGroupVoting.tsx |
Uses the member query. |
src/pages/EditionView/tabs/VoteTab/AuthedFilteredSetsPanel.tsx |
Uses the member query. |
src/contexts/ActiveScopeContext.tsx |
Reads member groups. |
src/components/layout/AppHeader/GroupsIndicator.tsx |
Reads member groups. |
src/api/groups/useUserGroups.ts |
Removes the combined query. |
src/api/groups/useMyGroups.ts |
Implements member-scoped fetching. |
src/api/groups/useMyGroups.integration.test.ts |
Tests member-group behavior. |
src/api/groups/useLeaveGroup.ts |
Invalidates both new query keys. |
src/api/groups/useJoinGroup.ts |
Invalidates both new query keys. |
src/api/groups/useDeleteGroup.ts |
Invalidates all group queries. |
src/api/groups/useCreateGroup.ts |
Invalidates all group queries. |
src/api/groups/useAllGroups.ts |
Implements privileged group fetching. |
src/api/groups/useAllGroups.integration.test.ts |
Tests fallback and super-admin behavior. |
src/api/groups/types.ts |
Defines separate query keys. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Playwright test resultsDetails
|
chiptus
commented
Sep 30, 2026
…dmin Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcvJ9ZU2F8T5fjAEm4otAW
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HcvJ9ZU2F8T5fjAEm4otAW
chiptus
commented
Oct 1, 2026
| } | ||
|
|
||
| // If not found as a member, check if user is the creator | ||
| // Not a member: let `groups` RLS decide (creator, or super admin who can read every group) |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Splits
useUserGroups'{ all }boolean (which flipped both the admin-gating andis_membersemantics behind one flag) intouseMyGroupsQuery(always member-scoped,is_memberalwaystrue) anduseAllGroupsQuery(admin view, falling back to the exact member-only result for non-admins). All call sites moved to the member-only hook except the Groups page's admin toggle, which now renders one of two sibling components instead of threading the boolean into a shared hook.UPL-16
Verification
/groups— your groups list renders the same as before./groups— behaves identically to before the split, including membership badges on the all-groups view.pnpm run typecheck,pnpm run lint, andpnpm testall pass.useMyGroups.integration.test.ts/useAllGroups.integration.test.tscover both paths (run viapnpm run test:integrationagainst a local Supabase instance).🤖 Generated with Claude Code
https://claude.ai/code/session_015AWdzYUiNjQwtASYbWTnaX
Generated by Claude Code