Fix to deeply nested function processHeaderChatLastGiven

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-09-07 11:34:59 +02:00
parent 5bb63fd58d
commit d0df4039c6
No known key found for this signature in database
GPG Key ID: FECE3A7222C52A4E

View File

@ -2486,17 +2486,23 @@ class ChatController(args: Bundle) :
private fun processHeaderChatLastGiven(response: Response<*>, isFromTheFuture: Boolean) {
val xChatLastGivenHeader: String? = response.headers()["X-Chat-Last-Given"]
if (response.headers().size > 0 && !TextUtils.isEmpty(xChatLastGivenHeader)) {
val header = Integer.parseInt(xChatLastGivenHeader!!)
if (header > 0) {
if (isFromTheFuture) {
val header = if (response.headers().size > 0 &&
xChatLastGivenHeader?.isNotEmpty() == true
) {
xChatLastGivenHeader.toInt()
} else {
return
}
if (header > 0) {
if (isFromTheFuture) {
globalLastKnownFutureMessageId = header
} else {
if (globalLastKnownFutureMessageId == -1) {
globalLastKnownFutureMessageId = header
} else {
if (globalLastKnownFutureMessageId == -1) {
globalLastKnownFutureMessageId = header
}
globalLastKnownPastMessageId = header
}
globalLastKnownPastMessageId = header
}
}
}