diff --git a/lib/services/collection_service.dart b/lib/services/collection_service.dart index 088b914..f2fee28 100644 --- a/lib/services/collection_service.dart +++ b/lib/services/collection_service.dart @@ -114,31 +114,14 @@ class CollectionService { final itemCounts = await getCollectionItemCounts(collectionIdList); final memberCounts = {}; - await Future.wait(collectionIdList.map((collectionId) async { - try { - final rows = await supabase.rpc('get_collection_members', params: { - 'p_collection_id': collectionId, - }); - memberCounts[collectionId] = (rows as List).length; - } catch (_) { - // Keep fallback below when RPC fails. - } - })); + final members = await supabase + .from('collection_members') + .select('collection_id') + .inFilter('collection_id', collectionIdList); - // Fallback member count for collections where RPC did not return data. - final unresolvedIds = collectionIdList - .where((id) => !memberCounts.containsKey(id)) - .toList(growable: false); - if (unresolvedIds.isNotEmpty) { - final members = await supabase - .from('collection_members') - .select('id, collection_id') - .inFilter('collection_id', unresolvedIds); - - for (final member in members) { - final collectionId = member['collection_id'] as String; - memberCounts[collectionId] = (memberCounts[collectionId] ?? 0) + 1; - } + for (final member in members) { + final collectionId = member['collection_id'] as String; + memberCounts[collectionId] = (memberCounts[collectionId] ?? 0) + 1; } final collections = [];