mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
Merge pull request #5024 from nextcloud/fixToNotShowContextSearchAccidentally
simplify how search results are shown
This commit is contained in:
commit
eb72c70520
@ -307,16 +307,11 @@ class ChatActivity :
|
|||||||
runBlocking {
|
runBlocking {
|
||||||
val id = intent?.getStringExtra(MessageSearchActivity.RESULT_KEY_MESSAGE_ID)
|
val id = intent?.getStringExtra(MessageSearchActivity.RESULT_KEY_MESSAGE_ID)
|
||||||
id?.let {
|
id?.let {
|
||||||
val isSaved = chatViewModel.isMessageSaved(id.toLong())
|
|
||||||
if (isSaved) {
|
|
||||||
onMessageSearchResult(intent)
|
|
||||||
} else {
|
|
||||||
startContextChatWindowForMessage(id)
|
startContextChatWindowForMessage(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun startContextChatWindowForMessage(id: String?) {
|
private fun startContextChatWindowForMessage(id: String?) {
|
||||||
binding.genericComposeView.apply {
|
binding.genericComposeView.apply {
|
||||||
@ -2297,13 +2292,6 @@ class ChatActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onMessageSearchResult(intent: Intent?) {
|
|
||||||
val messageId = intent?.getStringExtra(MessageSearchActivity.RESULT_KEY_MESSAGE_ID)
|
|
||||||
messageId?.let { id ->
|
|
||||||
scrollToAndCenterMessageWithId(id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun executeIfResultOk(result: ActivityResult, onResult: (intent: Intent?) -> Unit) {
|
private fun executeIfResultOk(result: ActivityResult, onResult: (intent: Intent?) -> Unit) {
|
||||||
if (result.resultCode == Activity.RESULT_OK) {
|
if (result.resultCode == Activity.RESULT_OK) {
|
||||||
onResult(result.data)
|
onResult(result.data)
|
||||||
@ -2319,7 +2307,7 @@ class ChatActivity :
|
|||||||
if (position != null && position >= 0) {
|
if (position != null && position >= 0) {
|
||||||
binding.messagesListView.scrollToPosition(position)
|
binding.messagesListView.scrollToPosition(position)
|
||||||
} else {
|
} else {
|
||||||
startContextChatWindowForMessage(messageId)
|
Log.d(TAG, "message $messageId that should be scrolled to was not found (scrollToMessageWithId)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2332,10 +2320,12 @@ class ChatActivity :
|
|||||||
binding.messagesListView.height / 2
|
binding.messagesListView.height / 2
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
startContextChatWindowForMessage(messageId)
|
Log.d(
|
||||||
|
TAG,
|
||||||
|
"message $messageId that should be scrolled " +
|
||||||
|
"to was not found (scrollToAndCenterMessageWithId)"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} ?: run {
|
|
||||||
startContextChatWindowForMessage(messageId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,8 +76,6 @@ interface ChatMessageRepository : LifecycleAwareManager {
|
|||||||
*/
|
*/
|
||||||
suspend fun getMessage(messageId: Long, bundle: Bundle): Flow<ChatMessage>
|
suspend fun getMessage(messageId: Long, bundle: Bundle): Flow<ChatMessage>
|
||||||
|
|
||||||
suspend fun checkIfMessageIsSaved(messageId: Long): Boolean
|
|
||||||
|
|
||||||
@Suppress("LongParameterList")
|
@Suppress("LongParameterList")
|
||||||
suspend fun sendChatMessage(
|
suspend fun sendChatMessage(
|
||||||
credentials: String,
|
credentials: String,
|
||||||
|
@ -475,15 +475,6 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
.map(ChatMessageEntity::asModel)
|
.map(ChatMessageEntity::asModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun checkIfMessageIsSaved(messageId: Long): Boolean {
|
|
||||||
try {
|
|
||||||
chatDao.getChatMessageForConversation(internalConversationId, messageId)
|
|
||||||
return true
|
|
||||||
} catch (_: Exception) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST", "MagicNumber", "Detekt.TooGenericExceptionCaught")
|
@Suppress("UNCHECKED_CAST", "MagicNumber", "Detekt.TooGenericExceptionCaught")
|
||||||
private fun getMessagesFromServer(bundle: Bundle): Pair<Int, List<ChatMessageJson>>? {
|
private fun getMessagesFromServer(bundle: Bundle): Pair<Int, List<ChatMessageJson>>? {
|
||||||
val fieldMap = bundle.getSerializable(BundleKeys.KEY_FIELD_MAP) as HashMap<String, Int>
|
val fieldMap = bundle.getSerializable(BundleKeys.KEY_FIELD_MAP) as HashMap<String, Int>
|
||||||
|
@ -285,10 +285,6 @@ class ChatViewModel @Inject constructor(
|
|||||||
conversationRepository.getRoom(token)
|
conversationRepository.getRoom(token)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun isMessageSaved(messageId: Long): Boolean {
|
|
||||||
return chatRepository.checkIfMessageIsSaved(messageId)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getCapabilities(user: User, token: String, conversationModel: ConversationModel) {
|
fun getCapabilities(user: User, token: String, conversationModel: ConversationModel) {
|
||||||
Log.d(TAG, "Remote server ${conversationModel.remoteServer}")
|
Log.d(TAG, "Remote server ${conversationModel.remoteServer}")
|
||||||
if (conversationModel.remoteServer.isNullOrEmpty()) {
|
if (conversationModel.remoteServer.isNullOrEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user