From 1b14914d37dc9827fffc48bd75f36600ee61f622 Mon Sep 17 00:00:00 2001 From: Joachim Favre Date: Fri, 3 May 2024 14:41:59 +0200 Subject: [PATCH 1/4] fix(challenge-repository): query crashes if whereIn has empty iterator --- lib/services/database/challenge_repository_service.dart | 6 ++++++ 1 file changed, 6 insertions(+) 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); From 6cc3ecbe9bbd811da07244984f7a7f7fc53b332b Mon Sep 17 00:00:00 2001 From: CHOOSEIT Date: Fri, 3 May 2024 14:50:39 +0200 Subject: [PATCH 2/4] feat(challenge_page): UI for challenge list page when not challenges available --- .../home_content/challenge/challenge_list.dart | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/views/home_content/challenge/challenge_list.dart b/lib/views/home_content/challenge/challenge_list.dart index 79a3023e..e3e2ee92 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 challenges 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(), + ), ); }, ); From 3aef58ca7c73026cd665adc21e76f62341567fef Mon Sep 17 00:00:00 2001 From: CHOOSEIT <53620532+CHOOSEIT@users.noreply.github.com> Date: Fri, 3 May 2024 14:56:02 +0200 Subject: [PATCH 3/4] fix(challenge_page): fix small typo empty challenge message Co-authored-by: Joachim Favre --- lib/views/home_content/challenge/challenge_list.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/views/home_content/challenge/challenge_list.dart b/lib/views/home_content/challenge/challenge_list.dart index e3e2ee92..a1f4325b 100644 --- a/lib/views/home_content/challenge/challenge_list.dart +++ b/lib/views/home_content/challenge/challenge_list.dart @@ -12,7 +12,7 @@ class ChallengeList extends ConsumerWidget { final asyncChallenges = ref.watch(challengeProvider); Widget emptyChallenge = const Center( - child: Text("No challenges available here"), + child: Text("No challenge available here!"), ); return CircularValue( From 2eb232202ad33ac1b4d2d0ef8475cef69ce9d1c9 Mon Sep 17 00:00:00 2001 From: CHOOSEIT <53620532+CHOOSEIT@users.noreply.github.com> Date: Fri, 3 May 2024 14:58:37 +0200 Subject: [PATCH 4/4] fix(challenge_page): remove unnecessary parenthesis in challenge emptiness checking Co-authored-by: Joachim Favre --- lib/views/home_content/challenge/challenge_list.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/views/home_content/challenge/challenge_list.dart b/lib/views/home_content/challenge/challenge_list.dart index a1f4325b..edbc4383 100644 --- a/lib/views/home_content/challenge/challenge_list.dart +++ b/lib/views/home_content/challenge/challenge_list.dart @@ -20,7 +20,7 @@ class ChallengeList extends ConsumerWidget { builder: (context, challenges) { return RefreshIndicator( onRefresh: () => ref.read(challengeProvider.notifier).refresh(), - child: (challenges.isEmpty) + child: challenges.isEmpty ? emptyChallenge : ListView( children: challenges