From cc2a7e180f5b1bbb500369577d9db1105c21ca59 Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Fri, 15 Oct 2021 14:10:59 +0200 Subject: [PATCH] Log is now updated if uncommited changes status changed --- src/main/kotlin/app/git/GitManager.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/app/git/GitManager.kt b/src/main/kotlin/app/git/GitManager.kt index 9a8182f..a4c4175 100644 --- a/src/main/kotlin/app/git/GitManager.kt +++ b/src/main/kotlin/app/git/GitManager.kt @@ -122,12 +122,21 @@ class GitManager @Inject constructor( fun loadLog() = managerScope.launch { coLoadLog() } - private suspend fun coLoadLog(){ + + private suspend fun coLoadLog() { logManager.loadLog(safeGit) } suspend fun loadStatus() { + val hadUncommitedChanges = statusManager.hasUncommitedChanges.value + statusManager.loadStatus(safeGit) + + val hasNowUncommitedChanges = statusManager.hasUncommitedChanges.value + + // Update the log only if the uncommitedChanges status has changed + if (hasNowUncommitedChanges != hadUncommitedChanges) + coLoadLog() } fun stage(diffEntry: DiffEntry) = managerScope.launch { @@ -153,14 +162,14 @@ class GitManager @Inject constructor( fun pull() = managerScope.launch { safeProcessing { remoteOperationsManager.pull(safeGit) - logManager.loadLog(safeGit) + coLoadLog() } } fun push() = managerScope.launch { safeProcessing { remoteOperationsManager.push(safeGit) - logManager.loadLog(safeGit) + coLoadLog() } }