mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-21 12:39:58 +01:00
Second attempt to fix the issue
Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
This commit is contained in:
parent
d064ad3f65
commit
d31e6de5c4
@ -239,7 +239,6 @@ class ChatController(args: Bundle) :
|
|||||||
val roomId: String
|
val roomId: String
|
||||||
val voiceOnly: Boolean
|
val voiceOnly: Boolean
|
||||||
var isFirstMessagesProcessing = true
|
var isFirstMessagesProcessing = true
|
||||||
var wasDetached: Boolean = false
|
|
||||||
var emojiPopup: EmojiPopup? = null
|
var emojiPopup: EmojiPopup? = null
|
||||||
|
|
||||||
var myFirstMessage: CharSequence? = null
|
var myFirstMessage: CharSequence? = null
|
||||||
@ -252,7 +251,6 @@ class ChatController(args: Bundle) :
|
|||||||
var magicWebSocketInstance: MagicWebSocketInstance? = null
|
var magicWebSocketInstance: MagicWebSocketInstance? = null
|
||||||
|
|
||||||
var lobbyTimerHandler: Handler? = null
|
var lobbyTimerHandler: Handler? = null
|
||||||
val roomJoined: Boolean = false
|
|
||||||
var pastPreconditionFailed = false
|
var pastPreconditionFailed = false
|
||||||
var futurePreconditionFailed = false
|
var futurePreconditionFailed = false
|
||||||
|
|
||||||
@ -1556,14 +1554,11 @@ class ChatController(args: Bundle) :
|
|||||||
|
|
||||||
cancelNotificationsForCurrentConversation()
|
cancelNotificationsForCurrentConversation()
|
||||||
|
|
||||||
Log.d(TAG, "onAttach inConversation: " + inConversation.toString() + " wasDetached: " + wasDetached.toString())
|
Log.d(TAG, "onAttach inConversation: " + inConversation.toString())
|
||||||
if (inConversation) {
|
if (inConversation) {
|
||||||
if (wasDetached) {
|
currentConversation?.sessionId = "0"
|
||||||
currentConversation?.sessionId = "0"
|
Log.d(TAG, "execute joinRoomWithPassword in onAttach")
|
||||||
wasDetached = false
|
joinRoomWithPassword()
|
||||||
Log.d(TAG, "execute joinRoomWithPassword in onAttach")
|
|
||||||
joinRoomWithPassword()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1602,8 +1597,9 @@ class ChatController(args: Bundle) :
|
|||||||
!ApplicationWideCurrentRoomHolder.getInstance().isDialing
|
!ApplicationWideCurrentRoomHolder.getInstance().isDialing
|
||||||
) {
|
) {
|
||||||
ApplicationWideCurrentRoomHolder.getInstance().clear()
|
ApplicationWideCurrentRoomHolder.getInstance().clear()
|
||||||
wasDetached = true
|
if (inConversation) {
|
||||||
leaveRoom()
|
leaveRoom()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mentionAutocomplete != null && mentionAutocomplete!!.isPopupShowing) {
|
if (mentionAutocomplete != null && mentionAutocomplete!!.isPopupShowing) {
|
||||||
@ -1779,11 +1775,6 @@ class ChatController(args: Bundle) :
|
|||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "magicWebSocketInstance or currentConversation were null! Failed to leave the room!")
|
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) {
|
override fun onError(e: Throwable) {
|
||||||
@ -1945,94 +1936,90 @@ class ChatController(args: Bundle) :
|
|||||||
fieldMap["lastCommonReadId"] = it
|
fieldMap["lastCommonReadId"] = it
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wasDetached) {
|
var apiVersion = 1
|
||||||
var apiVersion = 1
|
// FIXME this is a best guess, guests would need to get the capabilities themselves
|
||||||
// FIXME this is a best guess, guests would need to get the capabilities themselves
|
if (conversationUser != null) {
|
||||||
if (conversationUser != null) {
|
apiVersion = ApiUtils.getChatApiVersion(conversationUser, intArrayOf(1))
|
||||||
apiVersion = ApiUtils.getChatApiVersion(conversationUser, intArrayOf(1))
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (lookIntoFuture > 0) {
|
if (lookIntoFuture > 0) {
|
||||||
val finalTimeout = timeout
|
val finalTimeout = timeout
|
||||||
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture > 0] - calling")
|
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture > 0] - calling")
|
||||||
ncApi?.pullChatMessages(
|
ncApi?.pullChatMessages(
|
||||||
credentials,
|
credentials,
|
||||||
ApiUtils.getUrlForChat(apiVersion, conversationUser?.baseUrl, roomToken), fieldMap
|
ApiUtils.getUrlForChat(apiVersion, conversationUser?.baseUrl, roomToken), fieldMap
|
||||||
)
|
)
|
||||||
?.subscribeOn(Schedulers.io())
|
?.subscribeOn(Schedulers.io())
|
||||||
?.observeOn(AndroidSchedulers.mainThread())
|
?.observeOn(AndroidSchedulers.mainThread())
|
||||||
?.takeWhile { observable -> inConversation && !wasDetached }
|
?.subscribe(object : Observer<Response<*>> {
|
||||||
?.subscribe(object : Observer<Response<*>> {
|
override fun onSubscribe(d: Disposable) {
|
||||||
override fun onSubscribe(d: Disposable) {
|
disposableList.add(d)
|
||||||
disposableList.add(d)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@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")
|
||||||
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")
|
||||||
pullChatMessages(1, setReadMarker, xChatLastCommonRead)
|
pullChatMessages(1, setReadMarker, xChatLastCommonRead)
|
||||||
} else if (response.code() == 412) {
|
} else if (response.code() == 412) {
|
||||||
futurePreconditionFailed = true
|
futurePreconditionFailed = true
|
||||||
} else {
|
} else {
|
||||||
processMessages(response, true, finalTimeout)
|
processMessages(response, true, finalTimeout)
|
||||||
}
|
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchrously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
}
|
||||||
|
} catch (npe: NullPointerException) {
|
||||||
|
// view binding can be null
|
||||||
|
// since this is called asynchrously and UI might have been destroyed in the meantime
|
||||||
|
Log.i(TAG, "UI destroyed - view binding already gone")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
// unused atm
|
// unused atm
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture <= 0] - calling")
|
Log.d(TAG, "pullChatMessages - pullChatMessages[lookIntoFuture <= 0] - calling")
|
||||||
ncApi?.pullChatMessages(
|
ncApi?.pullChatMessages(
|
||||||
credentials,
|
credentials,
|
||||||
ApiUtils.getUrlForChat(apiVersion, conversationUser?.baseUrl, roomToken), fieldMap
|
ApiUtils.getUrlForChat(apiVersion, conversationUser?.baseUrl, roomToken), fieldMap
|
||||||
)
|
)
|
||||||
?.subscribeOn(Schedulers.io())
|
?.subscribeOn(Schedulers.io())
|
||||||
?.observeOn(AndroidSchedulers.mainThread())
|
?.observeOn(AndroidSchedulers.mainThread())
|
||||||
?.takeWhile { observable -> inConversation && !wasDetached }
|
?.subscribe(object : Observer<Response<*>> {
|
||||||
?.subscribe(object : Observer<Response<*>> {
|
override fun onSubscribe(d: Disposable) {
|
||||||
override fun onSubscribe(d: Disposable) {
|
disposableList.add(d)
|
||||||
disposableList.add(d)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@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")
|
||||||
try {
|
try {
|
||||||
if (response.code() == 412) {
|
if (response.code() == 412) {
|
||||||
pastPreconditionFailed = true
|
pastPreconditionFailed = true
|
||||||
} else {
|
} else {
|
||||||
processMessages(response, false, 0)
|
processMessages(response, false, 0)
|
||||||
}
|
|
||||||
} catch (npe: NullPointerException) {
|
|
||||||
// view binding can be null
|
|
||||||
// since this is called asynchrously and UI might have been destroyed in the meantime
|
|
||||||
Log.i(TAG, "UI destroyed - view binding already gone")
|
|
||||||
}
|
}
|
||||||
|
} catch (npe: NullPointerException) {
|
||||||
|
// view binding can be null
|
||||||
|
// since this is called asynchrously and UI might have been destroyed in the meantime
|
||||||
|
Log.i(TAG, "UI destroyed - view binding already gone")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
// unused atm
|
// unused atm
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user