likeForSubComment method
dynamic
likeForSubComment({})
Implementation
likeForSubComment(
{required int likeTypeId,
required String likeType,
required int mainCommentId,
required int subCommentID,
String? postId,
required String userId}) {
String isUpdateOrNew = "N";
int currentEmojiId = -1;
int updateLikeId = -1;
for (int x = 0;
x <
listOfComments[mainCommentId]
.replies[subCommentID]
.likesUsers
.length;
x++) {
if (userId ==
listOfComments[mainCommentId]
.replies[subCommentID]
.likesUsers[x]
.userId) {
if (listOfComments[mainCommentId]
.replies[subCommentID]
.likesUsers[x]
.emojiId !=
likeTypeId) {
isUpdateOrNew = "U";
currentEmojiId = listOfComments[mainCommentId]
.replies[subCommentID]
.likesUsers[x]
.emojiId;
updateLikeId = x;
} else {
isUpdateOrNew = "O";
return;
}
break;
}
}
if (isUpdateOrNew == "U") {
--listOfComments[mainCommentId]
.replies[subCommentID]
.commentLikeCounts[currentEmojiId]
.emojiCount;
++listOfComments[mainCommentId]
.replies[subCommentID]
.commentLikeCounts[likeTypeId]
.emojiCount;
listOfComments[mainCommentId]
.replies[subCommentID]
.likesUsers[updateLikeId]
.emoji = likeType;
listOfComments[mainCommentId]
.replies[subCommentID]
.likesUsers[updateLikeId]
.emojiId = likeTypeId;
} else if (isUpdateOrNew == "N") {
++listOfComments[mainCommentId]
.replies[subCommentID]
.commentLikeCounts[likeTypeId]
.emojiCount;
var like = LikedUser(userId, likeTypeId, likeType);
listOfComments[mainCommentId].replies[subCommentID].likesUsers.add(like);
} else {
return;
}
}