mirror of
https://github.com/CherretGit/zaprett-app.git
synced 2025-12-10 05:29:37 +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() {
|
||||
val targets = readActiveListsLines()
|
||||
var stopTest : Boolean = false;
|
||||
for (index in strategyStates.indices) {
|
||||
val current = strategyStates[index]
|
||||
if (stopTest) break
|
||||
strategyStates[index] = current.copy(status = StrategyTestingStatus.Testing)
|
||||
enableStrategy(current.path, prefs)
|
||||
if (prefs.getBoolean("use_module", false)) {
|
||||
getStatus { if (it) stopService { error ->
|
||||
_errorFlow.value = error
|
||||
if (error.isNotEmpty()) stopTest = true
|
||||
} }
|
||||
startService { error ->
|
||||
_errorFlow.value = error
|
||||
if (error.isNotEmpty()) stopTest = true
|
||||
}
|
||||
try {
|
||||
val progress = countReachable(index, targets)
|
||||
@@ -143,6 +147,7 @@ class StrategySelectionViewModel(application: Application) : AndroidViewModel(ap
|
||||
} finally {
|
||||
stopService { error ->
|
||||
_errorFlow.value = error
|
||||
if (error.isNotEmpty()) stopTest = true
|
||||
}
|
||||
disableStrategy(current.path, prefs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user