Skip to content

Commit

Permalink
Add check that local names collection is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
sandreae committed May 30, 2024
1 parent 93d671d commit 540e523
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/app/lib/models/local_names.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ class LocalNamesPaginator extends Paginator<LocalName> {
PaginatedCollection<LocalName> parseJSON(Map<String, dynamic> json) {
final list = json[DEFAULT_RESULTS_KEY]['documents'] as List;
final documents = list
.where((sighting) =>
sighting['fields']['local_names']['documents'][0] != null)
.where((sighting) {
List<dynamic> local_names =
sighting['fields']['local_names']['documents'] as List;
return local_names.isNotEmpty && local_names[0] != null;
})
.map((sighting) => LocalName.fromJson(sighting['fields']['local_names']
['documents'][0] as Map<String, dynamic>))
.toList();
Expand Down

0 comments on commit 540e523

Please sign in to comment.