Skip to content

Commit 3e89831

Browse files
authored
fix(community): eliminate per-member role API calls on members tab (#1079)
## Summary - `CommunityMemberCard` was calling `communityUserRoles` (a `entityRoles` API call) for each member individually - With 350 members, this resulted in 350 simultaneous requests, triggering HTTP 429 "Too many requests" - The roles are already present in the `communityUsersWithRoles` response - they are now passed as a prop, removing all redundant calls ## Changes - `CommunityMemberCard`: removed `communityUserRoles` query, accepts `roles: CommunityUserRole[]` as prop instead - `members.tsx`: passes `member.roles` (already fetched) to each card ## Test plan - [x] Go to a community with many members (e.g. `/community/4/members`) - [x] Verify the member list loads fully without 429 errors - [x] Verify role badges (member / administrator) still display correctly on each card Closes #1078
1 parent c7d8263 commit 3e89831

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

app/(general)/community/(general)/[id]/[tab]/members.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ function CommunityMembers({ communityId }: CommunityMembersProps) {
4242
>
4343
<Link href={`/profile/${member.entityId}`} className="block">
4444
<CommunityMemberCard
45-
communityId={communityId}
4645
userId={member.entityId}
46+
roles={member.roles}
4747
/>
4848
</Link>
4949
</Suspense>

components/user/community-member-card.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,15 @@ import { Card } from "../widgets/cards/card";
55
import Text from "../widgets/texts/text";
66
import { profileOptions } from "@/lib/queries/profile";
77
import { deserializeWithFrontMatter } from "@/lib/serialization";
8-
import { profileDetailsSchema } from "@/types/schemas";
9-
import { communityUserRoles } from "@/lib/queries/community";
8+
import { CommunityUserRole, profileDetailsSchema } from "@/types/schemas";
109

1110
type CommunityMemberCardProps = {
12-
communityId: string;
1311
userId: string;
12+
roles: CommunityUserRole[];
1413
};
1514

16-
function CommunityMemberCard({
17-
communityId,
18-
userId,
19-
}: CommunityMemberCardProps) {
15+
function CommunityMemberCard({ userId, roles }: CommunityMemberCardProps) {
2016
const { data: profile } = useSuspenseQuery(profileOptions(userId));
21-
const { data: roles = [] } = useSuspenseQuery(
22-
communityUserRoles(communityId, userId),
23-
);
2417

2518
if (!profile?.bio && !profile?.displayName && !profile?.avatarUri) {
2619
return null;

0 commit comments

Comments
 (0)