From 66686d760244ca4e289259acfde72246abb3bb03 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Fri, 15 Nov 2024 15:33:55 +0100 Subject: [PATCH] get correct api version for chat Signed-off-by: sowjanyakch --- .../talk/conversationinfo/ConversationInfoActivity.kt | 3 ++- .../conversationinfo/viewmodel/ConversationInfoViewModel.kt | 4 ++-- .../repositories/conversations/ConversationsRepository.kt | 2 +- .../repositories/conversations/ConversationsRepositoryImpl.kt | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt index 3a0593502..77ca78d55 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt @@ -746,7 +746,8 @@ class ConversationInfoActivity : } private fun clearHistory() { - viewModel.clearChatHistory(conversationToken) + val apiVersion = ApiUtils.getChatApiVersion(spreedCapabilities, intArrayOf(1)) + viewModel.clearChatHistory(apiVersion,conversationToken) } private fun deleteConversation() { diff --git a/app/src/main/java/com/nextcloud/talk/conversationinfo/viewmodel/ConversationInfoViewModel.kt b/app/src/main/java/com/nextcloud/talk/conversationinfo/viewmodel/ConversationInfoViewModel.kt index e746ca486..f24c994ed 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationinfo/viewmodel/ConversationInfoViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/viewmodel/ConversationInfoViewModel.kt @@ -285,10 +285,10 @@ class ConversationInfoViewModel @Inject constructor( conversationsRepository.unarchiveConversation(user.getCredentials(), url) } - fun clearChatHistory(roomToken:String){ + fun clearChatHistory(apiVersion:Int,roomToken:String){ viewModelScope.launch{ try{ - val clearChatResult = conversationsRepository.clearChatHistory(roomToken) + val clearChatResult = conversationsRepository.clearChatHistory(apiVersion,roomToken) val statusCode: GenericMeta? = clearChatResult.ocs?.meta val result = statusCode?.statusCode == STATUS_CODE_OK if (result) { diff --git a/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt b/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt index f20d0dbdf..c22e7f55f 100644 --- a/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepository.kt @@ -27,5 +27,5 @@ interface ConversationsRepository { fun setConversationReadOnly(credentials: String, url: String, state: Int): Observable - suspend fun clearChatHistory(roomToken:String): GenericOverall + suspend fun clearChatHistory(apiVersion:Int,roomToken:String): GenericOverall } diff --git a/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepositoryImpl.kt index fde1039f5..7e2ef91c5 100644 --- a/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepositoryImpl.kt +++ b/app/src/main/java/com/nextcloud/talk/repositories/conversations/ConversationsRepositoryImpl.kt @@ -92,9 +92,10 @@ class ConversationsRepositoryImpl( } override suspend fun clearChatHistory(roomToken:String): GenericOverall { + override suspend fun clearChatHistory(apiVersion:Int,roomToken:String): GenericOverall { return coroutineApi.clearChatHistory( credentials, - ApiUtils.getUrlForChat(apiVersion(), user.baseUrl!!, roomToken) + ApiUtils.getUrlForChat(apiVersion, user.baseUrl!!, roomToken) ) }