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,22 +2818,24 @@ class ChatActivity :
|
||||
DateFormatter.isSameDay(message1.createdAt, message2.createdAt)
|
||||
|
||||
override fun onLoadMore(page: Int, totalItemsCount: Int) {
|
||||
val id = (
|
||||
adapter?.items?.last {
|
||||
it.item is ChatMessage
|
||||
}?.item as ChatMessage
|
||||
).jsonMessageId
|
||||
val messageId = (
|
||||
adapter?.items
|
||||
?.lastOrNull { it.item is ChatMessage }
|
||||
?.item as? ChatMessage
|
||||
)?.jsonMessageId
|
||||
|
||||
messageId?.let {
|
||||
val urlForChatting = ApiUtils.getUrlForChat(chatApiVersion, conversationUser?.baseUrl, roomToken)
|
||||
|
||||
chatViewModel.loadMoreMessages(
|
||||
beforeMessageId = id.toLong(),
|
||||
beforeMessageId = it.toLong(),
|
||||
withUrl = urlForChatting,
|
||||
withCredentials = credentials!!,
|
||||
withMessageLimit = MESSAGE_PULL_LIMIT,
|
||||
roomToken = currentConversation!!.token
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun format(date: Date): String =
|
||||
if (DateFormatter.isToday(date)) {
|
||||
|
Loading…
Reference in New Issue
Block a user