Fixed clone state being lost on error & multiple errros not being reported
Also updated errors strings to better clarify the issue
This commit is contained in:
parent
716d04df9a
commit
1baab9e3f8
@ -72,7 +72,6 @@ private fun CloneInput(
|
||||
) {
|
||||
var url by remember { mutableStateOf(cloneViewModel.url) }
|
||||
var directory by remember { mutableStateOf(cloneViewModel.directory) }
|
||||
var errorHasBeenNoticed by remember { mutableStateOf(false) }
|
||||
|
||||
val urlFocusRequester = remember { FocusRequester() }
|
||||
val directoryFocusRequester = remember { FocusRequester() }
|
||||
@ -108,8 +107,9 @@ private fun CloneInput(
|
||||
maxLines = 1,
|
||||
value = url,
|
||||
onValueChange = {
|
||||
errorHasBeenNoticed = true
|
||||
cloneViewModel.resetStateIfError()
|
||||
url = it
|
||||
cloneViewModel.url = url
|
||||
}
|
||||
)
|
||||
|
||||
@ -132,14 +132,15 @@ private fun CloneInput(
|
||||
label = { Text("Directory") },
|
||||
value = directory,
|
||||
onValueChange = {
|
||||
errorHasBeenNoticed = true
|
||||
cloneViewModel.resetStateIfError()
|
||||
directory = it
|
||||
cloneViewModel.directory = directory
|
||||
}
|
||||
)
|
||||
|
||||
IconButton(
|
||||
onClick = {
|
||||
errorHasBeenNoticed = true
|
||||
cloneViewModel.resetStateIfError()
|
||||
val newDirectory = openDirectoryDialog()
|
||||
if (newDirectory != null)
|
||||
directory = newDirectory
|
||||
@ -158,7 +159,7 @@ private fun CloneInput(
|
||||
}
|
||||
}
|
||||
|
||||
AnimatedVisibility(errorMessage != null && !errorHasBeenNoticed) {
|
||||
AnimatedVisibility(errorMessage != null) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
@ -29,12 +29,12 @@ class CloneViewModel @Inject constructor(
|
||||
fun clone(directoryPath: String, url: String) {
|
||||
cloneJob = tabState.safeProcessingWihoutGit {
|
||||
if (directoryPath.isBlank()) {
|
||||
_cloneStatus.value = CloneStatus.Fail("Check your directory")
|
||||
_cloneStatus.value = CloneStatus.Fail("Invalid empty directory")
|
||||
return@safeProcessingWihoutGit
|
||||
}
|
||||
|
||||
if (url.isBlank()) {
|
||||
_cloneStatus.value = CloneStatus.Fail("Check your URL and try again")
|
||||
_cloneStatus.value = CloneStatus.Fail("Invalid empty URL")
|
||||
return@safeProcessingWihoutGit
|
||||
}
|
||||
|
||||
@ -87,4 +87,8 @@ class CloneViewModel @Inject constructor(
|
||||
cloneJob?.cancel()
|
||||
_cloneStatus.value = CloneStatus.Cancelling
|
||||
}
|
||||
|
||||
fun resetStateIfError() {
|
||||
_cloneStatus.value = CloneStatus.None
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user