Skip to content

Commit d9d47d2

Browse files
authored
Merge pull request #381 from andotherstuff/sortgroups
sort groups on list by members
2 parents 5d937b2 + 85241ca commit d9d47d2

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/pages/Groups.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,19 @@ export default function Groups() {
199199
return aPriority - bPriority;
200200
}
201201

202-
// If same priority, sort alphabetically by name
202+
// If same priority, sort by member count (descending), then alphabetically by name
203+
const aStats = communityStats ? communityStats[aId] : undefined;
204+
const bStats = communityStats ? communityStats[bId] : undefined;
205+
206+
const aMemberCount = aStats ? aStats.participants.size : 0;
207+
const bMemberCount = bStats ? bStats.participants.size : 0;
208+
209+
// Sort by member count (descending)
210+
if (aMemberCount !== bMemberCount) {
211+
return bMemberCount - aMemberCount;
212+
}
213+
214+
// If same member count, sort alphabetically by name
203215
const aNameTag = a.tags.find((tag) => tag[0] === "name");
204216
const bNameTag = b.tags.find((tag) => tag[0] === "name");
205217

@@ -218,6 +230,7 @@ export default function Groups() {
218230
isGroupPinned,
219231
userMembershipMap,
220232
pendingJoinRequestsSet,
233+
communityStats,
221234
]);
222235

223236
// Loading state skeleton with stable keys

0 commit comments

Comments
 (0)