feat: Refactor group deletion logic to use tripId and add reset trips functionality
This commit is contained in:
@@ -173,18 +173,30 @@ class GroupRepository {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteGroup(String groupId) async {
|
||||
try {
|
||||
final membersSnapshot = await _membersCollection(groupId).get();
|
||||
for (var doc in membersSnapshot.docs) {
|
||||
await doc.reference.delete();
|
||||
}
|
||||
|
||||
await _groupsCollection.doc(groupId).delete();
|
||||
} catch (e) {
|
||||
throw Exception('Erreur lors de la suppression du groupe: $e');
|
||||
Future<void> deleteGroup(String tripId) async {
|
||||
try {
|
||||
final querySnapshot = await _groupsCollection
|
||||
.where('tripId', isEqualTo: tripId)
|
||||
.limit(1)
|
||||
.get();
|
||||
|
||||
if (querySnapshot.docs.isEmpty) {
|
||||
throw Exception('Aucun groupe trouvé pour ce voyage');
|
||||
}
|
||||
|
||||
final groupDoc = querySnapshot.docs.first;
|
||||
final groupId = groupDoc.id;
|
||||
|
||||
final membersSnapshot = await _membersCollection(groupId).get();
|
||||
for (var doc in membersSnapshot.docs) {
|
||||
await doc.reference.delete();
|
||||
}
|
||||
|
||||
await _groupsCollection.doc(groupId).delete();
|
||||
} catch (e) {
|
||||
throw Exception('Erreur lors de la suppression du groupe: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Stream<List<GroupMember>> watchGroupMembers(String groupId) {
|
||||
return _membersCollection(groupId).snapshots().map(
|
||||
|
||||
Reference in New Issue
Block a user