diff --git a/lib/services/database/challenge_repository_service.dart b/lib/services/database/challenge_repository_service.dart index 8f25e421..984a95ff 100644 --- a/lib/services/database/challenge_repository_service.dart +++ b/lib/services/database/challenge_repository_service.dart @@ -144,6 +144,12 @@ class ChallengeRepositoryService { final Iterable possiblePosts = await _inRangeUnsortedPosts(pos, excludedUser); + + // The whereIn argument of the where method crashed + // if the query is empty for the real firestore. This + // cannot be tested with the mock firestore. + if (possiblePosts.isEmpty) return; + final Iterable possiblePostsStringIds = possiblePosts.map((post) => post.value); diff --git a/lib/views/home_content/challenge/challenge_list.dart b/lib/views/home_content/challenge/challenge_list.dart index 79a3023e..edbc4383 100644 --- a/lib/views/home_content/challenge/challenge_list.dart +++ b/lib/views/home_content/challenge/challenge_list.dart @@ -11,16 +11,22 @@ class ChallengeList extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final asyncChallenges = ref.watch(challengeProvider); + Widget emptyChallenge = const Center( + child: Text("No challenge available here!"), + ); + return CircularValue( value: asyncChallenges, builder: (context, challenges) { return RefreshIndicator( onRefresh: () => ref.read(challengeProvider.notifier).refresh(), - child: ListView( - children: challenges - .map((challenge) => ChallengeCard(challenge)) - .toList(), - ), + child: challenges.isEmpty + ? emptyChallenge + : ListView( + children: challenges + .map((challenge) => ChallengeCard(challenge)) + .toList(), + ), ); }, );