Skip to content

Commit

Permalink
[Temp FIX🔨] Empty Home screen for new user
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
AdarshRawat1 committed Feb 23, 2024
1 parent ead659d commit a890334
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions aid_employ/lib/features/post/repository/post_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ class PostRepository {
}

Stream<List<Post>> fetchUserPosts(List<Community> 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(
Expand All @@ -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<String, dynamic>,
// ),
// )
// .toList(),
// );
// }
}

Stream<List<Post>> fetchGuestPosts() {
return _posts.orderBy('createdAt', descending: true).limit(10).snapshots().map(
Expand Down

0 comments on commit a890334

Please sign in to comment.