Added delayed state change to processing state
This commit is contained in:
parent
878f6704d6
commit
1dff1d66b5
@ -2,6 +2,7 @@ package app.git
|
|||||||
|
|
||||||
import app.ErrorsManager
|
import app.ErrorsManager
|
||||||
import app.di.TabScope
|
import app.di.TabScope
|
||||||
|
import app.extensions.delayedStateChange
|
||||||
import app.newErrorNow
|
import app.newErrorNow
|
||||||
import app.ui.SelectedItem
|
import app.ui.SelectedItem
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
@ -61,10 +62,17 @@ class TabState @Inject constructor(
|
|||||||
managerScope.launch(Dispatchers.IO) {
|
managerScope.launch(Dispatchers.IO) {
|
||||||
mutex.withLock {
|
mutex.withLock {
|
||||||
var hasProcessFailed = false
|
var hasProcessFailed = false
|
||||||
_processing.value = true
|
operationRunning = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
callback(safeGit)
|
delayedStateChange(
|
||||||
|
delayMs = 300,
|
||||||
|
onDelayTriggered = {
|
||||||
|
_processing.value = true
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
callback(safeGit)
|
||||||
|
}
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
hasProcessFailed = true
|
hasProcessFailed = true
|
||||||
ex.printStackTrace()
|
ex.printStackTrace()
|
||||||
@ -73,6 +81,7 @@ class TabState @Inject constructor(
|
|||||||
errorsManager.addError(newErrorNow(ex, ex.message.orEmpty()))
|
errorsManager.addError(newErrorNow(ex, ex.message.orEmpty()))
|
||||||
} finally {
|
} finally {
|
||||||
_processing.value = false
|
_processing.value = false
|
||||||
|
operationRunning = false
|
||||||
|
|
||||||
if (refreshType != RefreshType.NONE && (!hasProcessFailed || refreshEvenIfCrashes))
|
if (refreshType != RefreshType.NONE && (!hasProcessFailed || refreshEvenIfCrashes))
|
||||||
_refreshData.emit(refreshType)
|
_refreshData.emit(refreshType)
|
||||||
|
Loading…
Reference in New Issue
Block a user