Reduce nested block depth for updateReadStatusOfAllMessages

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-09-07 10:51:09 +02:00
parent 57ddf9af60
commit 5bb63fd58d
No known key found for this signature in database
GPG key ID: FECE3A7222C52A4E

View file

@ -2352,18 +2352,25 @@ class ChatController(args: Bundle) :
private fun updateReadStatusOfAllMessages(xChatLastCommonRead: Int?) {
for (message in adapter!!.items) {
xChatLastCommonRead?.let {
updateReadStatusOfMessage(message, it)
}
}
}
private fun updateReadStatusOfMessage(
message: MessagesListAdapter<IMessage>.Wrapper<Any>,
xChatLastCommonRead: Int
) {
if (message.item is ChatMessage) {
val chatMessage = message.item as ChatMessage
if (chatMessage.jsonMessageId <= it) {
if (chatMessage.jsonMessageId <= xChatLastCommonRead) {
chatMessage.readStatus = ReadStatus.READ
} else {
chatMessage.readStatus = ReadStatus.SENT
}
}
}
}
}
private fun processMessagesFromTheFuture(chatMessageList: List<ChatMessage>) {
var chatMessage: ChatMessage