Skip to content

Commit

Permalink
Work on ktlint warnings
Browse files Browse the repository at this point in the history
Signed-off-by: sowjanyakch <[email protected]>
  • Loading branch information
sowjanyakch committed Sep 3, 2024
1 parent abcf95f commit 0c0e403
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class ContactsActivityCompose : BaseActivity() {
val uiState = contactsViewModel.contactsViewState.collectAsState()
val selectedParticipants = remember {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent.getParcelableArrayListExtra("selectedParticipants", AutocompleteUser::class.java) ?: emptyList()
intent.getParcelableArrayListExtra("selectedParticipants", AutocompleteUser::class.java)
?: emptyList()
} else {
@Suppress("DEPRECATION")
intent.getParcelableArrayListExtra("selectedParticipants") ?: emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class ContactsViewModel @Inject constructor(
val shareTypeList: List<String> = shareTypes
private val _searchState = MutableStateFlow(false)
val searchState: StateFlow<Boolean> = _searchState
private val _selectedParticipants = MutableStateFlow<List<AutocompleteUser>>(emptyList())
val selectedParticipantsList: StateFlow<List<AutocompleteUser>> = _selectedParticipants
private val selectedParticipants = MutableStateFlow<List<AutocompleteUser>>(emptyList())
val selectedParticipantsList: StateFlow<List<AutocompleteUser>> = selectedParticipants
private val _isAddParticipantsView = MutableStateFlow(false)
val isAddParticipantsView: StateFlow<Boolean> = _isAddParticipantsView

Expand All @@ -44,7 +44,7 @@ class ContactsViewModel @Inject constructor(
}

fun updateSelectedParticipants(participants: List<AutocompleteUser>) {
_selectedParticipants.value = participants
selectedParticipants.value = participants
}
fun updateSearchState(searchState: Boolean) {
_searchState.value = searchState
Expand Down Expand Up @@ -107,4 +107,3 @@ sealed class RoomUiState {
data class Success(val conversation: Conversation?) : RoomUiState()
data class Error(val message: String) : RoomUiState()
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ConversationCreationViewModel @Inject constructor(
) : ViewModel() {
private val _selectedParticipants = MutableStateFlow<List<AutocompleteUser>>(emptyList())
val selectedParticipants: StateFlow<List<AutocompleteUser>> = _selectedParticipants
private val _roomViewState = MutableStateFlow<RoomUIState>(RoomUIState.None)
private val roomViewState = MutableStateFlow<RoomUIState>(RoomUIState.None)

fun updateSelectedParticipants(participants: List<AutocompleteUser>) {
_selectedParticipants.value = participants
Expand All @@ -41,7 +41,7 @@ class ConversationCreationViewModel @Inject constructor(
var isConversationAvailableForRegisteredUsers = mutableStateOf(false)
var openForGuestAppUsers = mutableStateOf(false)
private val addParticipantsViewState = MutableStateFlow<AddParticipantsUiState>(AddParticipantsUiState.None)
private val _allowGuestsResult = MutableStateFlow<AllowGuestsUiState>(AllowGuestsUiState.None)
private val allowGuestsResult = MutableStateFlow<AllowGuestsUiState>(AllowGuestsUiState.None)
fun updateRoomName(roomName: String) {
_roomName.value = roomName
}
Expand All @@ -66,7 +66,7 @@ class ConversationCreationViewModel @Inject constructor(
else -> 0
}
viewModelScope.launch {
_roomViewState.value = RoomUIState.None
roomViewState.value = RoomUIState.None
try {
val roomResult = repository.createRoom(roomType, conversationName)
val conversation = roomResult.ocs?.data
Expand All @@ -75,15 +75,15 @@ class ConversationCreationViewModel @Inject constructor(
val token = conversation.token
if (token != null) {
try {
repository.setConversationDescription(
repository.setConversationDescription(
token,
_conversationDescription.value
)
val allowGuestsResult = repository.allowGuests(token, isGuestsAllowed.value)
val statusCode: GenericMeta? = allowGuestsResult.ocs?.meta
val allowGuestResultOverall = repository.allowGuests(token, isGuestsAllowed.value)
val statusCode: GenericMeta? = allowGuestResultOverall.ocs?.meta
val result = (statusCode?.statusCode == STATUS_CODE_OK)
if (result) {
_allowGuestsResult.value = AllowGuestsUiState.Success(result)
allowGuestsResult.value = AllowGuestsUiState.Success(result)
for (participant in participants) {
if (participant.id != null) {
val participantOverall = repository.addParticipants(
Expand All @@ -100,15 +100,15 @@ class ConversationCreationViewModel @Inject constructor(
repository.openConversation(token, scope)
onRoomCreated(token)
} catch (exception: Exception) {
_allowGuestsResult.value = AllowGuestsUiState.Error(exception.message ?: "")
allowGuestsResult.value = AllowGuestsUiState.Error(exception.message ?: "")
}
}
_roomViewState.value = RoomUIState.Success(conversation)
roomViewState.value = RoomUIState.Success(conversation)
} else {
_roomViewState.value = RoomUIState.Error("Conversation is null")
roomViewState.value = RoomUIState.Error("Conversation is null")
}
} catch (e: Exception) {
_roomViewState.value = RoomUIState.Error(e.message ?: "Unknown error")
roomViewState.value = RoomUIState.Error(e.message ?: "Unknown error")
Log.e("ConversationCreationViewModel", "Error - ${e.message}")
}
}
Expand All @@ -127,9 +127,9 @@ class ConversationCreationViewModel @Inject constructor(
)

val conversation: Conversation? = room.ocs?.data
_roomViewState.value = RoomUIState.Success(conversation)
roomViewState.value = RoomUIState.Success(conversation)
} catch (exception: Exception) {
_roomViewState.value = RoomUIState.Error(exception.message ?: "")
roomViewState.value = RoomUIState.Error(exception.message ?: "")
}
}
}
Expand All @@ -146,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<Conversation>?) : AddParticipantsUiState()
data class Error(val message: String) : AddParticipantsUiState()
Expand Down

0 comments on commit 0c0e403

Please sign in to comment.