mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-11 14:54:09 +01:00
Prevent overlapping pullChatMessages calls
Sometimes pullChatMessages may be called before response to a previous call is received. In such cases just ignore the second call. Message processing will continue when response to the earlier call is received. Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
This commit is contained in:
parent
b2aef87b24
commit
a7bd6393df
@ -233,6 +233,7 @@ class ChatController(args: Bundle) :
|
|||||||
var adapter: TalkMessagesListAdapter<ChatMessage>? = null
|
var adapter: TalkMessagesListAdapter<ChatMessage>? = null
|
||||||
var mentionAutocomplete: Autocomplete<*>? = null
|
var mentionAutocomplete: Autocomplete<*>? = null
|
||||||
var layoutManager: LinearLayoutManager? = null
|
var layoutManager: LinearLayoutManager? = null
|
||||||
|
var pullChatMessagesPending = false
|
||||||
var lookingIntoFuture = false
|
var lookingIntoFuture = false
|
||||||
var newMessagesCount = 0
|
var newMessagesCount = 0
|
||||||
var startCallFromNotification: Boolean? = null
|
var startCallFromNotification: Boolean? = null
|
||||||
@ -1902,6 +1903,16 @@ class ChatController(args: Bundle) :
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pullChatMessagesPending) {
|
||||||
|
// Sometimes pullChatMessages may be called before response to a previous call is received.
|
||||||
|
// In such cases just ignore the second call. Message processing will continue when response to the
|
||||||
|
// earlier call is received.
|
||||||
|
// More details: https://github.com/nextcloud/talk-android/pull/1766
|
||||||
|
Log.d(TAG, "pullChatMessages - pullChatMessagesPending is true, exiting")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pullChatMessagesPending = true
|
||||||
|
|
||||||
if (currentConversation != null && currentConversation!!.shouldShowLobby(conversationUser)) {
|
if (currentConversation != null && currentConversation!!.shouldShowLobby(conversationUser)) {
|
||||||
// return
|
// return
|
||||||
}
|
}
|
||||||
@ -1966,6 +1977,7 @@ class ChatController(args: Bundle) :
|
|||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
override fun onNext(response: Response<*>) {
|
override fun onNext(response: Response<*>) {
|
||||||
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture > 0] - got response")
|
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture > 0] - got response")
|
||||||
|
pullChatMessagesPending = false
|
||||||
try {
|
try {
|
||||||
if (response.code() == 304) {
|
if (response.code() == 304) {
|
||||||
Log.d(TAG, "pullChatMessages - quasi recursive call to pullChatMessages")
|
Log.d(TAG, "pullChatMessages - quasi recursive call to pullChatMessages")
|
||||||
@ -1984,10 +1996,11 @@ class ChatController(args: Bundle) :
|
|||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
Log.e(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture > 0] - ERROR", e)
|
Log.e(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture > 0] - ERROR", e)
|
||||||
|
pullChatMessagesPending = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
// unused atm
|
pullChatMessagesPending = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@ -2006,6 +2019,7 @@ class ChatController(args: Bundle) :
|
|||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
override fun onNext(response: Response<*>) {
|
override fun onNext(response: Response<*>) {
|
||||||
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture <= 0] - got response")
|
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture <= 0] - got response")
|
||||||
|
pullChatMessagesPending = false
|
||||||
try {
|
try {
|
||||||
if (response.code() == 412) {
|
if (response.code() == 412) {
|
||||||
pastPreconditionFailed = true
|
pastPreconditionFailed = true
|
||||||
@ -2021,10 +2035,11 @@ class ChatController(args: Bundle) :
|
|||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
Log.e(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture <= 0] - ERROR", e)
|
Log.e(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture <= 0] - ERROR", e)
|
||||||
|
pullChatMessagesPending = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
// unused atm
|
pullChatMessagesPending = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user