diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 9cbec68848..31042b6500 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -2685,12 +2685,14 @@ class ChatActivity : private fun isScrolledToBottom() = layoutManager?.findFirstVisibleItemPosition() == 0 private fun setUnreadMessageMarker(chatMessageList: List) { - val unreadChatMessage = ChatMessage() - unreadChatMessage.jsonMessageId = UNREAD_MESSAGES_MARKER_ID - unreadChatMessage.actorId = "-1" - unreadChatMessage.timestamp = chatMessageList[0].timestamp - unreadChatMessage.message = context.getString(R.string.nc_new_messages) - adapter?.addToStart(unreadChatMessage, false) + if (chatMessageList.isNotEmpty()) { + val unreadChatMessage = ChatMessage() + unreadChatMessage.jsonMessageId = UNREAD_MESSAGES_MARKER_ID + unreadChatMessage.actorId = "-1" + unreadChatMessage.timestamp = chatMessageList[0].timestamp + unreadChatMessage.message = context.getString(R.string.nc_new_messages) + adapter?.addToStart(unreadChatMessage, false) + } } private fun processMessagesNotFromTheFuture(chatMessageList: List) {