fix data import and export
Some checks failed
Pull Request Pipeline / test (pull_request) Successful in 2m8s
Pull Request Pipeline / lint (pull_request) Failing after 2m18s

This commit is contained in:
gelbeinhalb
2026-01-21 15:43:56 +01:00
parent bd5e38a3ca
commit 7339194ba0
5 changed files with 176 additions and 50 deletions

View File

@@ -23,22 +23,21 @@ class Group {
return 'Group{id: $id, name: $name, description: $description, members: $members}';
}
/// Creates a Group instance from a JSON object.
/// Creates a Group instance from a JSON object (memberIds format).
/// Player objects are reconstructed from memberIds by the DataTransferService.
Group.fromJson(Map<String, dynamic> json)
: id = json['id'],
createdAt = DateTime.parse(json['createdAt']),
name = json['name'],
description = json['description'],
members = (json['members'] as List)
.map((memberJson) => Player.fromJson(memberJson))
.toList();
members = []; // Populated during import via DataTransferService
/// Converts the Group instance to a JSON object.
/// Converts the Group instance to a JSON object using normalized format (memberIds only).
Map<String, dynamic> toJson() => {
'id': id,
'createdAt': createdAt.toIso8601String(),
'name': name,
'description': description,
'members': members.map((member) => member.toJson()).toList(),
'memberIds': members.map((member) => member.id).toList(),
};
}