From 7b4ab49a30248e47ad812a709937df34d3e807f4 Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Thu, 7 Apr 2022 22:50:52 +0200 Subject: [PATCH] Increased refresh time when having multiple consecutive changes to 1s and added refresh when diff missing --- src/main/kotlin/app/git/TabState.kt | 4 ++++ src/main/kotlin/app/viewmodels/DiffViewModel.kt | 1 + src/main/kotlin/app/viewmodels/TabViewModel.kt | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/app/git/TabState.kt b/src/main/kotlin/app/git/TabState.kt index 49054a9..69a070a 100644 --- a/src/main/kotlin/app/git/TabState.kt +++ b/src/main/kotlin/app/git/TabState.kt @@ -134,6 +134,10 @@ class TabState @Inject constructor( } } + suspend fun refreshData(refreshType: RefreshType) { + _refreshData.emit(refreshType) + } + fun newSelectedStash(stash: RevCommit) { newSelectedItem(SelectedItem.Stash(stash)) } diff --git a/src/main/kotlin/app/viewmodels/DiffViewModel.kt b/src/main/kotlin/app/viewmodels/DiffViewModel.kt index 2a360f9..39316de 100644 --- a/src/main/kotlin/app/viewmodels/DiffViewModel.kt +++ b/src/main/kotlin/app/viewmodels/DiffViewModel.kt @@ -54,6 +54,7 @@ class DiffViewModel @Inject constructor( _diffResult.value = ViewDiffResult.Loaded(diffEntryType, diffFormat) } catch (ex: Exception) { if(ex is MissingDiffEntryException) { + tabState.refreshData(refreshType = RefreshType.UNCOMMITED_CHANGES) _diffResult.value = ViewDiffResult.DiffNotFound } else ex.printStackTrace() diff --git a/src/main/kotlin/app/viewmodels/TabViewModel.kt b/src/main/kotlin/app/viewmodels/TabViewModel.kt index f05b204..947dd5f 100644 --- a/src/main/kotlin/app/viewmodels/TabViewModel.kt +++ b/src/main/kotlin/app/viewmodels/TabViewModel.kt @@ -20,7 +20,7 @@ import org.eclipse.jgit.lib.RepositoryState import java.io.File import javax.inject.Inject -private const val MIN_TIME_IN_MS_BETWEEN_REFRESHES = 500L +private const val MIN_TIME_IN_MS_BETWEEN_REFRESHES = 1000L /** * Contains all the information related to a tab and its subcomponents (smaller composables like the log, branches,