Second attempt to fix the issue

Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
This commit is contained in:
Dariusz Olszewski 2022-02-20 22:22:22 +01:00 committed by Marcel Hibbe
parent d064ad3f65
commit d31e6de5c4
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -239,7 +239,6 @@ class ChatController(args: Bundle) :
val roomId: String
val voiceOnly: Boolean
var isFirstMessagesProcessing = true
var wasDetached: Boolean = false
var emojiPopup: EmojiPopup? = null
var myFirstMessage: CharSequence? = null
@ -252,7 +251,6 @@ class ChatController(args: Bundle) :
var magicWebSocketInstance: MagicWebSocketInstance? = null
var lobbyTimerHandler: Handler? = null
val roomJoined: Boolean = false
var pastPreconditionFailed = false
var futurePreconditionFailed = false
@ -1556,16 +1554,13 @@ class ChatController(args: Bundle) :
cancelNotificationsForCurrentConversation()
Log.d(TAG, "onAttach inConversation: " + inConversation.toString() + " wasDetached: " + wasDetached.toString())
Log.d(TAG, "onAttach inConversation: " + inConversation.toString())
if (inConversation) {
if (wasDetached) {
currentConversation?.sessionId = "0"
wasDetached = false
Log.d(TAG, "execute joinRoomWithPassword in onAttach")
joinRoomWithPassword()
}
}
}
private fun cancelReply() {
binding.messageInputView.findViewById<RelativeLayout>(R.id.quotedChatMessageView)?.visibility = View.GONE
@ -1602,9 +1597,10 @@ class ChatController(args: Bundle) :
!ApplicationWideCurrentRoomHolder.getInstance().isDialing
) {
ApplicationWideCurrentRoomHolder.getInstance().clear()
wasDetached = true
if (inConversation) {
leaveRoom()
}
}
if (mentionAutocomplete != null && mentionAutocomplete!!.isPopupShowing) {
mentionAutocomplete?.dismissPopup()
@ -1779,11 +1775,6 @@ class ChatController(args: Bundle) :
} else {
Log.e(TAG, "magicWebSocketInstance or currentConversation were null! Failed to leave the room!")
}
if (!isDestroyed && !isBeingDestroyed && !wasDetached) {
Log.d(TAG, "leaveRoom - leaveRoom - popCurrentController")
router.popCurrentController()
}
}
override fun onError(e: Throwable) {
@ -1945,7 +1936,6 @@ class ChatController(args: Bundle) :
fieldMap["lastCommonReadId"] = it
}
if (!wasDetached) {
var apiVersion = 1
// FIXME this is a best guess, guests would need to get the capabilities themselves
if (conversationUser != null) {
@ -1961,7 +1951,6 @@ class ChatController(args: Bundle) :
)
?.subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread())
?.takeWhile { observable -> inConversation && !wasDetached }
?.subscribe(object : Observer<Response<*>> {
override fun onSubscribe(d: Disposable) {
disposableList.add(d)
@ -2002,7 +1991,6 @@ class ChatController(args: Bundle) :
)
?.subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread())
?.takeWhile { observable -> inConversation && !wasDetached }
?.subscribe(object : Observer<Response<*>> {
override fun onSubscribe(d: Disposable) {
disposableList.add(d)
@ -2034,7 +2022,6 @@ class ChatController(args: Bundle) :
})
}
}
}
private fun processMessages(response: Response<*>, isFromTheFuture: Boolean, timeout: Int) {
val xChatLastGivenHeader: String? = response.headers().get("X-Chat-Last-Given")