Skip to content

Commit

Permalink
fix: study_tags was null for new studies
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesvedder committed Jun 30, 2023
1 parent 04efdfc commit 212cfde
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions core/lib/src/models/tables/study.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Study extends SupabaseObjectFunctions<Study> {
Questionnaire? fhirQuestionnaire;

@JsonKey(includeToJson: false, includeFromJson: false)
late List<StudyTag> studyTags;
late List<StudyTag> studyTags = [];

@JsonKey(includeToJson: false, includeFromJson: false)
int participantCount = 0;
Expand Down Expand Up @@ -113,6 +113,8 @@ class Study extends SupabaseObjectFunctions<Study> {
tag: Tag.fromJson(json as Map<String, dynamic>),
),
).toList();
} else {
study.studyTags = [];
}

final List? repo = json['repo'] as List?;
Expand Down Expand Up @@ -169,14 +171,6 @@ class Study extends SupabaseObjectFunctions<Study> {
@override
Map<String, dynamic> toJson() => _$StudyToJson(this);

/*List<Tag> get selectedStudyTags {
final selectedStudyTags = selectedStudyTagIds.map(
(selectedStudyTagId) =>
studyTags.singleWhere((studyTag) => studyTag.id == selectedStudyTagId),
).toList();
return selectedStudyTags;
}*/

// TODO: Add null checks in fromJson to allow selecting columns
static Future<List<Study>> getResearcherDashboardStudies() async => SupabaseQuery.getAll<Study>(
selectedColumns: [
Expand Down

0 comments on commit 212cfde

Please sign in to comment.