Skip to content

Commit fb99696

Browse files
committed
🐛 (fix) Tweet like count
🐛 (fix) Notification page displays 0 people like your tweet
1 parent 41827d6 commit fb99696

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

lib/model/feedModel.dart

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,26 @@ class FeedModel {
7272
}
7373
if (map["likeList"] != null) {
7474
likeList = List<String>();
75-
try {
76-
final list = map['likeList'];
77-
if (list is List) {
78-
map['likeList'].forEach((value) {
75+
76+
final list = map['likeList'];
77+
/// In new tweet db schema likeList is stored as a List<String>()
78+
///
79+
if (list is List) {
80+
map['likeList'].forEach((value) {
81+
if (value is String) {
7982
likeList.add(value);
80-
});
81-
likeCount = likeList.length ?? 0;
82-
}
83-
} catch (e) {
84-
likeCount = 0;
85-
likeList = [];
83+
}
84+
});
85+
likeCount = likeList.length ?? 0;
86+
}
87+
/// In old database tweet db schema likeList is saved in the form of map
88+
/// like list map is removed from latest code but to support old schema below code is required
89+
/// Once all user migrated to new version like list map support will be removed
90+
else if(list is Map){
91+
list.forEach((key, value) {
92+
likeList.add(value["userId"]);
93+
});
94+
likeCount = list.length;
8695
}
8796
} else {
8897
likeList = [];

lib/page/common/usersListPage.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class UsersListPage extends StatelessWidget {
3636
icon: appBarIcon),
3737
body: Consumer<SearchState>(
3838
builder: (context, state, child) {
39-
if (userIdsList != null) {
39+
if (userIdsList != null && userIdsList.isNotEmpty) {
4040
userList = state.getuserDetail(userIdsList);
4141
}
4242
return !(userList != null && userList.isNotEmpty)

lib/widgets/tweet/widgets/tweetIconsRow.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class TweetIconsRow extends StatelessWidget {
3131

3232
Widget _likeCommentsIcons(BuildContext context, FeedModel model) {
3333
var authState = Provider.of<AuthState>(context, listen: false);
34+
3435
return Container(
3536
color: Colors.transparent,
3637
padding: EdgeInsets.only(bottom: 0, top: 0),
@@ -229,6 +230,8 @@ class TweetIconsRow extends StatelessWidget {
229230
builder: (BuildContext context) => UsersListPage(
230231
pageTitle: "Liked by",
231232
userIdsList: model.likeList.map((userId) => userId).toList(),
233+
emptyScreenText: "This tweet has no like yet",
234+
emptyScreenSubTileText: "Once a user likes this tweet, user list will be shown here",
232235
),
233236
),
234237
);

0 commit comments

Comments
 (0)