fix(ui): prevent duplication in comment and post creation

This commit is contained in:
Diego Beraldin 2023-09-26 13:29:37 +02:00
parent 77f9e6ed03
commit 09b4e5f526
2 changed files with 10 additions and 2 deletions

View File

@ -47,6 +47,10 @@ class CreateCommentViewModel(
}
private fun submit() {
if (mvi.uiState.value.loading) {
return
}
mvi.updateState {
it.copy(
textError = null,
@ -66,8 +70,8 @@ class CreateCommentViewModel(
return
}
mvi.updateState { it.copy(loading = true) }
mvi.scope?.launch(Dispatchers.IO) {
mvi.updateState { it.copy(loading = true) }
try {
val auth = identityRepository.authToken.value.orEmpty()
if (postId != null) {

View File

@ -76,6 +76,10 @@ class CreatePostViewModel(
}
private fun submit() {
if (mvi.uiState.value.loading) {
return
}
mvi.updateState {
it.copy(
titleError = null,
@ -116,8 +120,8 @@ class CreatePostViewModel(
return
}
mvi.updateState { it.copy(loading = true) }
mvi.scope?.launch(Dispatchers.IO) {
mvi.updateState { it.copy(loading = true) }
try {
val auth = identityRepository.authToken.value.orEmpty()
when {