From 1dff1d66b530b3ca2ca8241e6a5577244b7b99a2 Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Sat, 11 Jun 2022 13:37:09 +0200 Subject: [PATCH] Added delayed state change to processing state --- src/main/kotlin/app/git/TabState.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/app/git/TabState.kt b/src/main/kotlin/app/git/TabState.kt index d00fa00..3c5054c 100644 --- a/src/main/kotlin/app/git/TabState.kt +++ b/src/main/kotlin/app/git/TabState.kt @@ -2,6 +2,7 @@ package app.git import app.ErrorsManager import app.di.TabScope +import app.extensions.delayedStateChange import app.newErrorNow import app.ui.SelectedItem import kotlinx.coroutines.* @@ -61,10 +62,17 @@ class TabState @Inject constructor( managerScope.launch(Dispatchers.IO) { mutex.withLock { var hasProcessFailed = false - _processing.value = true + operationRunning = true try { - callback(safeGit) + delayedStateChange( + delayMs = 300, + onDelayTriggered = { + _processing.value = true + } + ) { + callback(safeGit) + } } catch (ex: Exception) { hasProcessFailed = true ex.printStackTrace() @@ -73,6 +81,7 @@ class TabState @Inject constructor( errorsManager.addError(newErrorNow(ex, ex.message.orEmpty())) } finally { _processing.value = false + operationRunning = false if (refreshType != RefreshType.NONE && (!hasProcessFailed || refreshEvenIfCrashes)) _refreshData.emit(refreshType)