File tree Expand file tree Collapse file tree 3 files changed +23
-11
lines changed Expand file tree Collapse file tree 3 files changed +23
-11
lines changed Original file line number Diff line number Diff 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 = [];
Original file line number Diff line number Diff 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)
Original file line number Diff line number Diff 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 );
You can’t perform that action at this time.
0 commit comments