From bd177cedccc1ffb54312019e3f1b44e258febbb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20M=C3=BCllner?= Date: Thu, 5 Mar 2026 10:46:30 +0100 Subject: [PATCH] fix: resolve invite overflow and member removal lookup --- lib/screens/manage_collection_screen.dart | 81 ++++++++++++----------- lib/services/collection_service.dart | 7 +- 2 files changed, 47 insertions(+), 41 deletions(-) diff --git a/lib/screens/manage_collection_screen.dart b/lib/screens/manage_collection_screen.dart index ecc2ea4..e2556e4 100644 --- a/lib/screens/manage_collection_screen.dart +++ b/lib/screens/manage_collection_screen.dart @@ -146,45 +146,50 @@ class _ManageCollectionScreenState extends State { child: const Icon(Icons.person_add, color: Colors.white, size: 28), ), title: const Text('Invite Member'), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const Text( - 'Enter the email address of the person you want to invite. ' - 'They must already have an account.', - style: TextStyle( - fontSize: 13, - color: AppColors.textSecondary, - ), - ), - const SizedBox(height: 16), - TextField( - controller: emailCtrl, - autofocus: true, - keyboardType: TextInputType.emailAddress, - decoration: const InputDecoration( - labelText: 'Email address', - hintText: 'user@example.com', - prefixIcon: Icon(Icons.email_outlined), - ), - ), - const SizedBox(height: 12), - DropdownButtonFormField( - initialValue: inviteRole, - decoration: const InputDecoration( - labelText: 'Role', - prefixIcon: Icon(Icons.security_outlined), - ), - items: const [ - DropdownMenuItem(value: 'member', child: Text('Member (can add/copy/edit)')), - DropdownMenuItem(value: 'viewer', child: Text('Viewer (read-only)')), + content: SingleChildScrollView( + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 420), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Text( + 'Enter the email address of the person you want to invite. ' + 'They must already have an account.', + style: TextStyle( + fontSize: 13, + color: AppColors.textSecondary, + ), + ), + const SizedBox(height: 16), + TextField( + controller: emailCtrl, + autofocus: true, + keyboardType: TextInputType.emailAddress, + decoration: const InputDecoration( + labelText: 'Email address', + hintText: 'user@example.com', + prefixIcon: Icon(Icons.email_outlined), + ), + ), + const SizedBox(height: 12), + DropdownButtonFormField( + initialValue: inviteRole, + decoration: const InputDecoration( + labelText: 'Role', + prefixIcon: Icon(Icons.security_outlined), + ), + items: const [ + DropdownMenuItem(value: 'member', child: Text('Member (can add/copy/edit)')), + DropdownMenuItem(value: 'viewer', child: Text('Viewer (read-only)')), + ], + onChanged: (value) { + if (value == null) return; + setSheetState(() => inviteRole = value); + }, + ), ], - onChanged: (value) { - if (value == null) return; - setSheetState(() => inviteRole = value); - }, ), - ], + ), ), actions: [ TextButton( @@ -256,7 +261,7 @@ class _ManageCollectionScreenState extends State { try { await CollectionService.removeMember( collectionId: _collection.id, - membershipId: member.id, + memberUserId: member.userId, ); showGlobalSnackBar('Member removed.'); await _loadMembers(); diff --git a/lib/services/collection_service.dart b/lib/services/collection_service.dart index 497067b..361aaf8 100644 --- a/lib/services/collection_service.dart +++ b/lib/services/collection_service.dart @@ -326,7 +326,7 @@ class CollectionService { /// Remove a member from a collection. static Future removeMember({ required String collectionId, - required String membershipId, + required String memberUserId, }) async { final currentUserId = supabase.auth.currentUser!.id; @@ -346,7 +346,7 @@ class CollectionService { final target = await supabase .from('collection_members') .select('role, user_id') - .eq('id', membershipId) + .eq('user_id', memberUserId) .eq('collection_id', collectionId) .maybeSingle(); @@ -360,7 +360,8 @@ class CollectionService { await supabase .from('collection_members') .delete() - .eq('id', membershipId); + .eq('user_id', memberUserId) + .eq('collection_id', collectionId); } /// Leave a collection (for non-owners).