diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 7f3de2a7d..10e2d09dd 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -264,7 +264,6 @@ class ChatController(args: Bundle) : private var mentionAutocomplete: Autocomplete<*>? = null var layoutManager: LinearLayoutManager? = null var pullChatMessagesPending = false - private var lookingIntoFuture = false var newMessagesCount = 0 var startCallFromNotification: Boolean? = null var startCallFromRoomSwitch: Boolean = false @@ -2256,9 +2255,7 @@ class ChatController(args: Bundle) : val fieldMap = HashMap() fieldMap["includeLastKnown"] = 0 - if (lookIntoFuture) { - lookingIntoFuture = true - } else if (isFirstMessagesProcessing) { + if (!lookIntoFuture && isFirstMessagesProcessing) { if (currentConversation != null) { globalLastKnownFutureMessageId = currentConversation!!.lastReadMessage globalLastKnownPastMessageId = currentConversation!!.lastReadMessage @@ -2266,13 +2263,14 @@ class ChatController(args: Bundle) : } } - val timeout = if (lookingIntoFuture) { + val timeout = if (lookIntoFuture) { LOOKING_INTO_FUTURE_TIMEOUT } else { 0 } fieldMap["timeout"] = timeout + fieldMap["limit"] = MESSAGE_PULL_LIMIT if (lookIntoFuture) { fieldMap["lookIntoFuture"] = 1 @@ -2280,8 +2278,6 @@ class ChatController(args: Bundle) : fieldMap["lookIntoFuture"] = 0 } - fieldMap["limit"] = MESSAGE_PULL_LIMIT - if (setReadMarker) { fieldMap["setReadMarker"] = 1 } else { @@ -2376,7 +2372,10 @@ class ChatController(args: Bundle) : } } - private fun processMessagesResponse(response: Response<*>, isFromTheFuture: Boolean) { + private fun processMessagesResponse( + response: Response<*>, + isFromTheFuture: Boolean + ) { val xChatLastCommonRead = response.headers()["X-Chat-Last-Common-Read"]?.let { Integer.parseInt(it) } @@ -2398,9 +2397,7 @@ class ChatController(args: Bundle) : historyRead = true - if (!lookingIntoFuture && validSessionId()) { - pullChatMessages(true) - } + pullChatMessages(true) } }