Fixed issues with sending messages

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2019-09-30 14:53:35 +02:00
parent f308a5093d
commit 345035e93a

View file

@ -229,7 +229,6 @@ class ChatController(args: Bundle) : BaseController(args), MessagesListAdapter
override fun onNext(roomOverall: RoomOverall) { override fun onNext(roomOverall: RoomOverall) {
currentConversation = roomOverall.ocs.data currentConversation = roomOverall.ocs.data
loadAvatarForStatusBar() loadAvatarForStatusBar()
setTitle() setTitle()
@ -904,8 +903,8 @@ class ChatController(args: Bundle) : BaseController(args), MessagesListAdapter
fieldMap["includeLastKnown"] = 0 fieldMap["includeLastKnown"] = 0
var timeout = 30 var timeout = 30
if (lookIntoFuture == 0 || !lookingIntoFuture) { if (!lookingIntoFuture) {
timeout = 0 timeout = 0;
} }
fieldMap["timeout"] = timeout fieldMap["timeout"] = timeout
@ -917,8 +916,6 @@ class ChatController(args: Bundle) : BaseController(args), MessagesListAdapter
globalLastKnownFutureMessageId = currentConversation!!.lastReadMessage globalLastKnownFutureMessageId = currentConversation!!.lastReadMessage
globalLastKnownPastMessageId = currentConversation!!.lastReadMessage globalLastKnownPastMessageId = currentConversation!!.lastReadMessage
fieldMap["includeLastKnown"] = 1 fieldMap["includeLastKnown"] = 1
} else {
return;
} }
} }
@ -938,9 +935,7 @@ class ChatController(args: Bundle) : BaseController(args), MessagesListAdapter
if (!wasDetached) { if (!wasDetached) {
if (lookIntoFuture > 0) { if (lookIntoFuture > 0) {
val finalTimeout = timeout val finalTimeout = timeout
ncApi?.pullChatMessages(credentials, ApiUtils.getUrlForChat(conversationUser?.baseUrl, ncApi?.pullChatMessages(credentials, ApiUtils.getUrlForChat(conversationUser?.baseUrl, roomToken), fieldMap)
roomToken),
fieldMap)
?.subscribeOn(Schedulers.io()) ?.subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread()) ?.observeOn(AndroidSchedulers.mainThread())
?.takeWhile { observable -> inConversation && !wasDetached } ?.takeWhile { observable -> inConversation && !wasDetached }
@ -950,7 +945,11 @@ class ChatController(args: Bundle) : BaseController(args), MessagesListAdapter
} }
override fun onNext(response: Response<*>) { override fun onNext(response: Response<*>) {
processMessages(response, true, finalTimeout) if (response.code() == 304) {
pullChatMessages(1)
} else {
processMessages(response, true, finalTimeout)
}
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) {