Use correct model

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-11-27 18:18:18 +01:00 committed by Marcel Hibbe
parent 54d1512fff
commit 5fd8541ddc
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
2 changed files with 5 additions and 16 deletions

View File

@ -6,9 +6,10 @@
*/
package com.nextcloud.talk.openconversations.data
import com.nextcloud.talk.models.json.conversations.Conversation
import io.reactivex.Observable
interface OpenConversationsRepository {
fun fetchConversations(): Observable<OpenConversationsModel>
fun fetchConversations(): Observable<List<Conversation>>
}

View File

@ -21,23 +21,11 @@ class OpenConversationsRepositoryImpl(private val ncApi: NcApi, currentUserProvi
val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V3, 1))
override fun fetchConversations(): Observable<OpenConversationsModel> {
return ncApi.getOpenConversations(
override fun fetchConversations(): Observable<List<Conversation>> {
val roomOverall = ncApi.getOpenConversations(
credentials,
ApiUtils.getUrlForOpenConversations(apiVersion, currentUser.baseUrl!!)
).map { mapToOpenConversationsModel(it.ocs?.data!!) }
}
private fun mapToOpenConversationsModel(conversations: List<Conversation>): OpenConversationsModel {
return OpenConversationsModel(
conversations.map { conversation ->
OpenConversation(
// conversation.roomId!!,
conversation.token!!,
conversation.name!!,
conversation.description ?: ""
)
}
)
return roomOverall.map { it.ocs?.data!! }
}
}