Refactor (delete lookingIntoFuture)

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-03-06 17:43:22 +01:00
parent 7065b18d07
commit 6f4a24b28f
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -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<String, Int>()
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,11 +2397,9 @@ class ChatController(args: Bundle) :
historyRead = true
if (!lookingIntoFuture && validSessionId()) {
pullChatMessages(true)
}
}
}
private fun processMessages(
chatMessageList: List<ChatMessage>,