From cde8617501cd3025e8910d3d3a98819a0b8ee8d1 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Tue, 3 Sep 2024 10:58:06 +0200 Subject: [PATCH] Work on warnings Signed-off-by: sowjanyakch --- .../talk/contacts/ContactsViewModel.kt | 5 -- .../ConversationCreationActivity.kt | 3 +- .../ConversationCreationViewModel.kt | 52 ++----------------- 3 files changed, 4 insertions(+), 56 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/contacts/ContactsViewModel.kt b/app/src/main/java/com/nextcloud/talk/contacts/ContactsViewModel.kt index c1ba90db2c7..3c2e6dcc477 100644 --- a/app/src/main/java/com/nextcloud/talk/contacts/ContactsViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/contacts/ContactsViewModel.kt @@ -108,8 +108,3 @@ sealed class RoomUiState { data class Error(val message: String) : RoomUiState() } -sealed class AddParticipantsUiState() { - data object None : AddParticipantsUiState() - data class Success(val participants: List?) : AddParticipantsUiState() - data class Error(val message: String) : AddParticipantsUiState() -} diff --git a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt index 6f016b94c21..440173fb413 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt @@ -103,7 +103,6 @@ class ConversationCreationActivity : BaseActivity() { @OptIn(ExperimentalMaterial3Api::class) @Composable fun ConversationCreationScreen(conversationCreationViewModel: ConversationCreationViewModel, context: Context) { - val context = LocalContext.current val launcher = rememberLauncherForActivityResult( contract = ActivityResultContracts.StartActivityForResult(), @@ -159,7 +158,7 @@ fun DefaultUserAvatar() { ) { AsyncImage( model = R.drawable.ic_circular_group, - contentDescription = "User Avatar", + contentDescription = stringResource(id = R.string.user_avatar), modifier = Modifier .size(width = 84.dp, height = 84.dp) .padding(top = 8.dp) diff --git a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt index 97d6163491c..d9c7846a4e7 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt @@ -26,7 +26,6 @@ class ConversationCreationViewModel @Inject constructor( private val _selectedParticipants = MutableStateFlow>(emptyList()) val selectedParticipants: StateFlow> = _selectedParticipants private val _roomViewState = MutableStateFlow(RoomUIState.None) - val roomViewState: StateFlow = _roomViewState fun updateSelectedParticipants(participants: List) { _selectedParticipants.value = participants @@ -55,51 +54,6 @@ class ConversationCreationViewModel @Inject constructor( _conversationDescription.value = conversationDescription } - fun renameConversation(roomToken: String) { - viewModelScope.launch { - try { - repository.renameConversation(roomToken, roomName.value) - } catch (e: Exception) { - Log.d("ConversationCreationViewModel", "${e.message}") - } - } - } - - fun setConversationDescription(roomToken: String) { - viewModelScope.launch { - try { - repository.setConversationDescription(roomToken, conversationDescription.value) - } catch (e: Exception) { - Log.d("ConversationCreationViewModel", "${e.message}") - } - } - } - - fun addParticipants(conversationToken: String?, userId: String, sourceType: String) { - viewModelScope.launch { - try { - val participantsOverall = repository.addParticipants(conversationToken, userId, sourceType) - val participants: List? = participantsOverall.ocs?.data - addParticipantsViewState.value = AddParticipantsUiState.Success(participants) - } catch (exception: Exception) { - addParticipantsViewState.value = AddParticipantsUiState.Error(exception.message ?: "") - } - } - } - - fun allowGuests(token: String, allow: Boolean) { - viewModelScope.launch { - try { - val response = repository.allowGuests(token, allow) - val statusCode: Int = response.ocs?.meta?.statusCode!! - val result = (statusCode == STATUS_CODE_OK) - _allowGuestsResult.value = AllowGuestsUiState.Success(result) - } catch (exception: Exception) { - _allowGuestsResult.value = AllowGuestsUiState.Error(exception.message ?: "") - } - } - } - fun createRoomAndAddParticipants( roomType: String, conversationName: String, @@ -121,7 +75,7 @@ class ConversationCreationViewModel @Inject constructor( val token = conversation.token if (token != null) { try { - val conversationDescription = repository.setConversationDescription( + repository.setConversationDescription( token, _conversationDescription.value ) @@ -142,7 +96,7 @@ class ConversationCreationViewModel @Inject constructor( } } } - val passwordResult = repository.setPassword(token, _password.value) + repository.setPassword(token, _password.value) repository.openConversation(token, scope) onRoomCreated(token) } catch (exception: Exception) { @@ -192,7 +146,7 @@ sealed class RoomUIState { data class Error(val message: String) : RoomUIState() } -sealed class AddParticipantsUiState() { +sealed class AddParticipantsUiState{ data object None : AddParticipantsUiState() data class Success(val participants: List?) : AddParticipantsUiState() data class Error(val message: String) : AddParticipantsUiState()