Skip to content

Commit

Permalink
✨ date state null 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
sooziini committed Sep 19, 2024
1 parent 33ede2f commit 1aaa60d
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,24 @@ class EventCreationViewModel @Inject constructor(
}

private fun createEvent(description: String, fileList: List<File>) {
viewModelScope.launch {
createEventUseCase(
groupId = groupId,
description = description,
date = uiState.value.date?.let {
LocalDateUtil.parseLongToLocalDateTime(it).toString()
} ?: "",
fileList = fileList,
).onSuccess {
_uiState.update { it.copy(eventCreationSuccess = groupId) }
updateLoadingState(isLoading = false)
}.onFailure {
showErrorSnackBar()
updateLoadingState(isLoading = false)
uiState.value.date?.let { date ->
viewModelScope.launch {
createEventUseCase(
groupId = groupId,
description = description,
date = LocalDateUtil.parseLongToLocalDateTime(date).toString(),
fileList = fileList,
).onSuccess {
_uiState.update { it.copy(eventCreationSuccess = groupId) }
updateLoadingState(isLoading = false)
}.onFailure {
showErrorSnackBar()
updateLoadingState(isLoading = false)
}
}
} ?: {
showErrorSnackBar()
updateLoadingState(isLoading = false)
}
}

Expand Down

0 comments on commit 1aaa60d

Please sign in to comment.