From a890334b3d44362e5e54f25f473fb5641c96d0c8 Mon Sep 17 00:00:00 2001 From: Adarsh Date: Fri, 23 Feb 2024 23:01:06 +0530 Subject: [PATCH] =?UTF-8?q?[Temp=20FIX=F0=9F=94=A8]=20Empty=20Home=20scree?= =?UTF-8?q?n=20for=20new=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # bug - New users had no post in feed section # Description Reason being that users are supposed to see post from the communities that they are a part of but for a new user it can be a bit confusing. # Solution Show latest 7 post to user thus improving the UX. # fix - Added 7 latest post to home screen --- .../post/repository/post_repository.dart | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/aid_employ/lib/features/post/repository/post_repository.dart b/aid_employ/lib/features/post/repository/post_repository.dart index ebec1c6..f5c2623 100644 --- a/aid_employ/lib/features/post/repository/post_repository.dart +++ b/aid_employ/lib/features/post/repository/post_repository.dart @@ -34,11 +34,8 @@ class PostRepository { } Stream> fetchUserPosts(List communities) { - return _posts - .where('communityName', whereIn: communities.map((e) => e.name).toList()) - .orderBy('createdAt', descending: true) - .snapshots() - .map( + // if(communities.map((e) => e.name).toList().isEmpty){ + return _posts.orderBy('createdAt', descending: true).limit(7).snapshots().map( (event) => event.docs .map( (e) => Post.fromMap( @@ -47,7 +44,23 @@ class PostRepository { ) .toList(), ); - } + // } + // else{ + // return _posts + // .where('communityName', whereIn: communities.map((e) => e.name).toList()) + // .orderBy('createdAt', descending: true) + // .snapshots() + // .map( + // (event) => event.docs + // .map( + // (e) => Post.fromMap( + // e.data() as Map, + // ), + // ) + // .toList(), + // ); + // } + } Stream> fetchGuestPosts() { return _posts.orderBy('createdAt', descending: true).limit(10).snapshots().map(