Added fallbacks for groups when same group already exists

This commit is contained in:
2025-11-16 19:01:58 +01:00
parent 02735b5b1d
commit 5c09dfb47d

View File

@@ -38,7 +38,8 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
/// Adds a new group with the given [id] and [name] to the database. /// Adds a new group with the given [id] and [name] to the database.
/// This method also adds the group's members to the [PlayerGroupTable]. /// This method also adds the group's members to the [PlayerGroupTable].
Future<void> addGroup({required Group group}) async { Future<bool> addGroup({required Group group}) async {
if (!await groupExists(groupId: group.id)) {
await db.transaction(() async { await db.transaction(() async {
await into( await into(
groupTable, groupTable,
@@ -59,8 +60,11 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
await Future.wait( await Future.wait(
group.members.map((player) => db.playerDao.addPlayer(player: player)), group.members.map((player) => db.playerDao.addPlayer(player: player)),
); );
return true;
}); });
} }
return false;
}
/// Deletes the group with the given [id] from the database. /// Deletes the group with the given [id] from the database.
/// Returns `true` if more than 0 rows were affected, otherwise `false`. /// Returns `true` if more than 0 rows were affected, otherwise `false`.