Created
September 26, 2021 17:14
-
-
Save a914-gowtham/61e22b121562da9c2526b10507f3cfc3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Transaction | |
@Query("SELECT * FROM `Group`") | |
fun getGroupWithMessagesList(): List<GroupWithMessages> | |
\\ chathandler.kt | |
val groupsWithMsgs = dbRepository.getGroupWithMessagesList() | |
for (groupWithMsg in groupsWithMsgs) { | |
val unreadCount = groupWithMsg.messages.filter { | |
val myMessageStatus = Utils.myMsgStatus(userId.toString(), it) | |
it.from != userId && myMessageStatus < 3 | |
}.size | |
groupWithMsg.group.unRead = unreadCount | |
} | |
dbRepository.insertMultipleGroup(groups) | |
```utils.kt | |
fun myMsgStatus(myUserId: String, msg: GroupMessage): Int{ | |
val indexOfMyStatus=msg.to.indexOf(myUserId) | |
return msg.status[indexOfMyStatus] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment