add participants

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-08-14 10:57:37 +02:00 committed by Marcel Hibbe
parent 9ae0d524c0
commit 6a01309f2f
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
5 changed files with 35 additions and 11 deletions

View file

@ -12,6 +12,7 @@ import android.app.Activity
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.util.Log
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
@ -197,6 +198,8 @@ fun ContactItemRow(
fun AppBar(title: String, context: Context, contactsViewModel: ContactsViewModel) { fun AppBar(title: String, context: Context, contactsViewModel: ContactsViewModel) {
val searchQuery by contactsViewModel.searchQuery.collectAsState() val searchQuery by contactsViewModel.searchQuery.collectAsState()
val searchState = contactsViewModel.searchState.collectAsState() val searchState = contactsViewModel.searchState.collectAsState()
val addParticipantsUiState = contactsViewModel.addParticipantsUiState.collectAsState()
val conversationToken:String? = null
TopAppBar( TopAppBar(
title = { Text(text = title) }, title = { Text(text = title) },
@ -217,11 +220,38 @@ fun AppBar(title: String, context: Context, contactsViewModel: ContactsViewModel
Text( Text(
text = stringResource(id = R.string.nc_contacts_done), text = stringResource(id = R.string.nc_contacts_done),
modifier = Modifier.clickable { modifier = Modifier.clickable {
for(contacts in contactsViewModel.selectedParticipantsList){
contacts.let { contact ->
contactsViewModel.addParticipants(
conversationToken,
contact.id!!,
contact.source!!
)
}
}
} }
) )
} }
} }
) )
val state = addParticipantsUiState.value
when(state){
is AddParticipantsUiState.Error -> {
val errorMessage = state.message
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Text(text = "Error: $errorMessage", color = Color.Red)
}
}
is AddParticipantsUiState.None -> {
}
is AddParticipantsUiState.Success -> {
val conversation = state.participants
Log.d("ContactsActivityCompose", "$conversation")
}
}
if (searchState.value) { if (searchState.value) {
Row { Row {
DisplaySearch( DisplaySearch(
@ -232,13 +262,6 @@ fun AppBar(title: String, context: Context, contactsViewModel: ContactsViewModel
}, },
contactsViewModel = contactsViewModel contactsViewModel = contactsViewModel
) )
if (contactsViewModel.isAddParticipantsView.value) {
Text(
text = stringResource(id = R.string.nc_contacts_done),
modifier = Modifier.clickable {
}
)
}
} }
} }
} }

View file

@ -15,5 +15,5 @@ interface ContactsRepository {
suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall
suspend fun createRoom(roomType: String, sourceType: String, userId: String, conversationName: String?): RoomOverall suspend fun createRoom(roomType: String, sourceType: String, userId: String, conversationName: String?): RoomOverall
fun getImageUri(avatarId: String, requestBigSize: Boolean): String fun getImageUri(avatarId: String, requestBigSize: Boolean): String
suspend fun addParticipants(conversationToken: String, userId: String, sourceType: String): AddParticipantOverall suspend fun addParticipants(conversationToken: String?, userId: String, sourceType: String): AddParticipantOverall
} }

View file

@ -77,7 +77,7 @@ class ContactsRepositoryImpl(
} }
override suspend fun addParticipants( override suspend fun addParticipants(
conversationToken: String, conversationToken: String?,
userId: String, userId: String,
sourceType: String sourceType: String
): AddParticipantOverall { ): AddParticipantOverall {

View file

@ -96,7 +96,7 @@ class ContactsViewModel @Inject constructor(
fun getImageUri(avatarId: String, requestBigSize: Boolean): String { fun getImageUri(avatarId: String, requestBigSize: Boolean): String {
return repository.getImageUri(avatarId, requestBigSize) return repository.getImageUri(avatarId, requestBigSize)
} }
fun addParticipants(conversationToken: String, userId: String, sourceType: String) { fun addParticipants(conversationToken: String?, userId: String, sourceType: String){
viewModelScope.launch { viewModelScope.launch {
try { try {
val participantsOverall = repository.addParticipants(conversationToken, userId, sourceType) val participantsOverall = repository.addParticipants(conversationToken, userId, sourceType)

View file

@ -79,6 +79,7 @@ import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.arbitrarystorage.ArbitraryStorageManager import com.nextcloud.talk.arbitrarystorage.ArbitraryStorageManager
import com.nextcloud.talk.chat.ChatActivity import com.nextcloud.talk.chat.ChatActivity
import com.nextcloud.talk.contacts.ContactsActivity
import com.nextcloud.talk.contacts.ContactsActivityCompose import com.nextcloud.talk.contacts.ContactsActivityCompose
import com.nextcloud.talk.conversationlist.viewmodels.ConversationsListViewModel import com.nextcloud.talk.conversationlist.viewmodels.ConversationsListViewModel
import com.nextcloud.talk.data.network.NetworkMonitor import com.nextcloud.talk.data.network.NetworkMonitor
@ -1066,7 +1067,7 @@ class ConversationsListActivity :
conversation.type === ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL conversation.type === ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL
private fun showNewConversationsScreen() { private fun showNewConversationsScreen() {
val intent = Intent(context, ContactsActivityCompose::class.java) val intent = Intent(context, ContactsActivity::class.java)
intent.putExtra(KEY_NEW_CONVERSATION, true) intent.putExtra(KEY_NEW_CONVERSATION, true)
startActivity(intent) startActivity(intent)
} }