mirror of
https://github.com/CherretGit/zaprett-app.git
synced 2025-12-10 13:39:41 +05:00
add autostop on strategy testing error
This commit is contained in:
@@ -122,16 +122,20 @@ class StrategySelectionViewModel(application: Application) : AndroidViewModel(ap
|
|||||||
}
|
}
|
||||||
suspend fun performTest() {
|
suspend fun performTest() {
|
||||||
val targets = readActiveListsLines()
|
val targets = readActiveListsLines()
|
||||||
|
var stopTest : Boolean = false;
|
||||||
for (index in strategyStates.indices) {
|
for (index in strategyStates.indices) {
|
||||||
val current = strategyStates[index]
|
val current = strategyStates[index]
|
||||||
|
if (stopTest) break
|
||||||
strategyStates[index] = current.copy(status = StrategyTestingStatus.Testing)
|
strategyStates[index] = current.copy(status = StrategyTestingStatus.Testing)
|
||||||
enableStrategy(current.path, prefs)
|
enableStrategy(current.path, prefs)
|
||||||
if (prefs.getBoolean("use_module", false)) {
|
if (prefs.getBoolean("use_module", false)) {
|
||||||
getStatus { if (it) stopService { error ->
|
getStatus { if (it) stopService { error ->
|
||||||
_errorFlow.value = error
|
_errorFlow.value = error
|
||||||
|
if (error.isNotEmpty()) stopTest = true
|
||||||
} }
|
} }
|
||||||
startService { error ->
|
startService { error ->
|
||||||
_errorFlow.value = error
|
_errorFlow.value = error
|
||||||
|
if (error.isNotEmpty()) stopTest = true
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
val progress = countReachable(index, targets)
|
val progress = countReachable(index, targets)
|
||||||
@@ -143,6 +147,7 @@ class StrategySelectionViewModel(application: Application) : AndroidViewModel(ap
|
|||||||
} finally {
|
} finally {
|
||||||
stopService { error ->
|
stopService { error ->
|
||||||
_errorFlow.value = error
|
_errorFlow.value = error
|
||||||
|
if (error.isNotEmpty()) stopTest = true
|
||||||
}
|
}
|
||||||
disableStrategy(current.path, prefs)
|
disableStrategy(current.path, prefs)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user