Merge pull request #4567 from nextcloud/issue-4454-fix-msg-input-fragment-join-open-convo

Fixed bug that hides message input upon joining open conversations
This commit is contained in:
Marcel Hibbe 2025-01-14 17:19:54 +00:00 committed by GitHub
commit f39b1ddc19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 67 additions and 64 deletions

View File

@ -676,7 +676,7 @@ class ChatActivity :
} }
} }
updateRoomTimerHandler() updateRoomTimerHandler(MILLIS_250)
val urlForChatting = val urlForChatting =
ApiUtils.getUrlForChat(chatApiVersion, conversationUser?.baseUrl, roomToken) ApiUtils.getUrlForChat(chatApiVersion, conversationUser?.baseUrl, roomToken)
@ -1614,7 +1614,7 @@ class ChatActivity :
currentConversation?.type != null && currentConversation?.type != null &&
currentConversation?.type == ConversationEnums.ConversationType.ROOM_PUBLIC_CALL currentConversation?.type == ConversationEnums.ConversationType.ROOM_PUBLIC_CALL
private fun updateRoomTimerHandler() { private fun updateRoomTimerHandler(delay: Long = -1) {
val delayForRecursiveCall = if (shouldShowLobby()) { val delayForRecursiveCall = if (shouldShowLobby()) {
GET_ROOM_INFO_DELAY_LOBBY GET_ROOM_INFO_DELAY_LOBBY
} else { } else {
@ -1628,7 +1628,7 @@ class ChatActivity :
{ {
chatViewModel.getRoom(roomToken) chatViewModel.getRoom(roomToken)
}, },
delayForRecursiveCall if (delay > 0) delay else delayForRecursiveCall
) )
} }
@ -1722,7 +1722,7 @@ class ChatActivity :
val curMsg = adapter?.items?.getOrNull(index - i)?.item val curMsg = adapter?.items?.getOrNull(index - i)?.item
if (curMsg is ChatMessage) { if (curMsg is ChatMessage) {
if (nextMessage == null && i > 0) { if (nextMessage == null && i > 0) {
nextMessage = curMsg as ChatMessage nextMessage = curMsg
} }
if (curMsg.isVoiceMessage) { if (curMsg.isVoiceMessage) {
@ -1733,7 +1733,7 @@ class ChatActivity :
val filename = curMsg.selectedIndividualHashMap!!["name"] val filename = curMsg.selectedIndividualHashMap!!["name"]
val file = File(context.cacheDir, filename!!) val file = File(context.cacheDir, filename!!)
if (!file.exists()) { if (!file.exists()) {
downloadFileToCache(curMsg as ChatMessage, false) { downloadFileToCache(curMsg, false) {
curMsg.isDownloadingVoiceMessage = false curMsg.isDownloadingVoiceMessage = false
curMsg.voiceMessageDuration = try { curMsg.voiceMessageDuration = try {
val retriever = MediaMetadataRetriever() val retriever = MediaMetadataRetriever()
@ -2168,9 +2168,18 @@ class ChatActivity :
private fun checkLobbyState() { private fun checkLobbyState() {
if (currentConversation != null && if (currentConversation != null &&
ConversationUtils.isLobbyViewApplicable(currentConversation!!, spreedCapabilities) ConversationUtils.isLobbyViewApplicable(currentConversation!!, spreedCapabilities) &&
shouldShowLobby()
) { ) {
if (shouldShowLobby()) { showLobbyView()
} else {
binding.lobby.lobbyView.visibility = View.GONE
binding.messagesListView.visibility = View.VISIBLE
checkShowMessageInputView()
}
}
private fun showLobbyView() {
binding.lobby.lobbyView.visibility = View.VISIBLE binding.lobby.lobbyView.visibility = View.VISIBLE
binding.messagesListView.visibility = View.GONE binding.messagesListView.visibility = View.GONE
binding.fragmentContainerActivityChat.visibility = View.GONE binding.fragmentContainerActivityChat.visibility = View.GONE
@ -2197,16 +2206,6 @@ class ChatActivity :
sb.append(currentConversation!!.description) sb.append(currentConversation!!.description)
binding.lobby.lobbyTextView.text = sb.toString() binding.lobby.lobbyTextView.text = sb.toString()
} else {
binding.lobby.lobbyView.visibility = View.GONE
binding.messagesListView.visibility = View.VISIBLE
checkShowMessageInputView()
}
} else {
binding.lobby.lobbyView.visibility = View.GONE
binding.messagesListView.visibility = View.VISIBLE
checkShowMessageInputView()
}
} }
private fun onRemoteFileBrowsingResult(intent: Intent?) { private fun onRemoteFileBrowsingResult(intent: Intent?) {
@ -4028,6 +4027,7 @@ class ChatActivity :
private const val UNREAD_MESSAGES_MARKER_ID = -1 private const val UNREAD_MESSAGES_MARKER_ID = -1
private const val GET_ROOM_INFO_DELAY_NORMAL: Long = 30000 private const val GET_ROOM_INFO_DELAY_NORMAL: Long = 30000
private const val GET_ROOM_INFO_DELAY_LOBBY: Long = 5000 private const val GET_ROOM_INFO_DELAY_LOBBY: Long = 5000
private const val MILLIS_250 = 250L
private const val AGE_THRESHOLD_FOR_DELETE_MESSAGE: Int = 21600000 // (6 hours in millis = 6 * 3600 * 1000) private const val AGE_THRESHOLD_FOR_DELETE_MESSAGE: Int = 21600000 // (6 hours in millis = 6 * 3600 * 1000)
private const val REQUEST_SHARE_FILE_PERMISSION: Int = 221 private const val REQUEST_SHARE_FILE_PERMISSION: Int = 221
private const val REQUEST_RECORD_AUDIO_PERMISSION = 222 private const val REQUEST_RECORD_AUDIO_PERMISSION = 222

View File

@ -69,11 +69,6 @@ class OfflineFirstConversationsRepository @Inject constructor(
override fun getRoom(roomToken: String): Job = override fun getRoom(roomToken: String): Job =
scope.launch { scope.launch {
val id = user.id!!
val model = getConversation(id, roomToken)
if (model != null) {
_conversationFlow.emit(model)
} else {
chatNetworkDataSource.getRoom(user, roomToken) chatNetworkDataSource.getRoom(user, roomToken)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
?.observeOn(AndroidSchedulers.mainThread()) ?.observeOn(AndroidSchedulers.mainThread())
@ -83,7 +78,16 @@ class OfflineFirstConversationsRepository @Inject constructor(
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) {
// unused atm runBlocking {
// In case network is offline or call fails
val id = user.id!!
val model = getConversation(id, roomToken)
if (model != null) {
_conversationFlow.emit(model)
} else {
Log.e(TAG, "Conversation model not found on device database")
}
}
} }
override fun onComplete() { override fun onComplete() {
@ -99,7 +103,6 @@ class OfflineFirstConversationsRepository @Inject constructor(
} }
}) })
} }
}
@Suppress("Detekt.TooGenericExceptionCaught") @Suppress("Detekt.TooGenericExceptionCaught")
private suspend fun getRoomsFromServer(): List<ConversationEntity>? { private suspend fun getRoomsFromServer(): List<ConversationEntity>? {