mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
Merge pull request #4865 from nextcloud/bugfix/4864/fixNpeOnLoadMore
avoid NPE in onLoadMore
This commit is contained in:
commit
d617d65af2
@ -2818,21 +2818,23 @@ class ChatActivity :
|
|||||||
DateFormatter.isSameDay(message1.createdAt, message2.createdAt)
|
DateFormatter.isSameDay(message1.createdAt, message2.createdAt)
|
||||||
|
|
||||||
override fun onLoadMore(page: Int, totalItemsCount: Int) {
|
override fun onLoadMore(page: Int, totalItemsCount: Int) {
|
||||||
val id = (
|
val messageId = (
|
||||||
adapter?.items?.last {
|
adapter?.items
|
||||||
it.item is ChatMessage
|
?.lastOrNull { it.item is ChatMessage }
|
||||||
}?.item as ChatMessage
|
?.item as? ChatMessage
|
||||||
).jsonMessageId
|
)?.jsonMessageId
|
||||||
|
|
||||||
val urlForChatting = ApiUtils.getUrlForChat(chatApiVersion, conversationUser?.baseUrl, roomToken)
|
messageId?.let {
|
||||||
|
val urlForChatting = ApiUtils.getUrlForChat(chatApiVersion, conversationUser?.baseUrl, roomToken)
|
||||||
|
|
||||||
chatViewModel.loadMoreMessages(
|
chatViewModel.loadMoreMessages(
|
||||||
beforeMessageId = id.toLong(),
|
beforeMessageId = it.toLong(),
|
||||||
withUrl = urlForChatting,
|
withUrl = urlForChatting,
|
||||||
withCredentials = credentials!!,
|
withCredentials = credentials!!,
|
||||||
withMessageLimit = MESSAGE_PULL_LIMIT,
|
withMessageLimit = MESSAGE_PULL_LIMIT,
|
||||||
roomToken = currentConversation!!.token
|
roomToken = currentConversation!!.token
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun format(date: Date): String =
|
override fun format(date: Date): String =
|
||||||
|
Loading…
Reference in New Issue
Block a user