parent
0bebd43eb4
commit
762212fabe
2 changed files with 25 additions and 4 deletions
|
@ -5,6 +5,7 @@ import androidx.compose.foundation.lazy.LazyListState
|
||||||
import androidx.compose.ui.text.input.TextFieldValue
|
import androidx.compose.ui.text.input.TextFieldValue
|
||||||
import com.jetpackduba.gitnuro.extensions.delayedStateChange
|
import com.jetpackduba.gitnuro.extensions.delayedStateChange
|
||||||
import com.jetpackduba.gitnuro.extensions.filePath
|
import com.jetpackduba.gitnuro.extensions.filePath
|
||||||
|
import com.jetpackduba.gitnuro.extensions.fullData
|
||||||
import com.jetpackduba.gitnuro.extensions.lowercaseContains
|
import com.jetpackduba.gitnuro.extensions.lowercaseContains
|
||||||
import com.jetpackduba.gitnuro.git.RefreshType
|
import com.jetpackduba.gitnuro.git.RefreshType
|
||||||
import com.jetpackduba.gitnuro.git.TabState
|
import com.jetpackduba.gitnuro.git.TabState
|
||||||
|
@ -63,15 +64,36 @@ class CommitChangesViewModel @Inject constructor(
|
||||||
// Check if it's a different commit before resetting everything
|
// Check if it's a different commit before resetting everything
|
||||||
if (
|
if (
|
||||||
state is CommitChangesState.Loading ||
|
state is CommitChangesState.Loading ||
|
||||||
state is CommitChangesState.Loaded && state.commit != commit
|
state is CommitChangesState.Loaded //&& state.commit != commit
|
||||||
) {
|
) {
|
||||||
delayedStateChange(
|
delayedStateChange(
|
||||||
delayMs = MIN_TIME_IN_MS_TO_SHOW_LOAD,
|
delayMs = MIN_TIME_IN_MS_TO_SHOW_LOAD,
|
||||||
onDelayTriggered = { _commitChangesState.value = CommitChangesState.Loading }
|
onDelayTriggered = { _commitChangesState.value = CommitChangesState.Loading }
|
||||||
) {
|
) {
|
||||||
val changes = getCommitDiffEntriesUseCase(git, commit)
|
val fullCommit = commit.fullData(git.repository)
|
||||||
|
|
||||||
_commitChangesState.value = CommitChangesState.Loaded(commit, changes, changes)
|
if (fullCommit != null) {
|
||||||
|
val changes = getCommitDiffEntriesUseCase(git, fullCommit).toMutableList()
|
||||||
|
|
||||||
|
if (fullCommit.parentCount == 3) {
|
||||||
|
val untrackedFilesCommit =
|
||||||
|
fullCommit.parents?.firstOrNull {
|
||||||
|
val parentCommit = it.fullData(git.repository) ?: return@firstOrNull false
|
||||||
|
|
||||||
|
parentCommit.fullMessage.startsWith("untracked files on") && parentCommit.parentCount == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if (untrackedFilesCommit != null) {
|
||||||
|
val untrackedFilesChanges = getCommitDiffEntriesUseCase(git, untrackedFilesCommit)
|
||||||
|
|
||||||
|
if(untrackedFilesChanges.all { it.changeType == DiffEntry.ChangeType.ADD }) { // All files should be new
|
||||||
|
changes.addAll(untrackedFilesChanges)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_commitChangesState.value = CommitChangesState.Loaded(commit, changes, changes)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_showSearch.value = false
|
_showSearch.value = false
|
||||||
|
|
|
@ -58,7 +58,6 @@ class MenuViewModel @Inject constructor(
|
||||||
fun stash() = tabState.safeProcessing(
|
fun stash() = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.UNCOMMITED_CHANGES_AND_LOG,
|
refreshType = RefreshType.UNCOMMITED_CHANGES_AND_LOG,
|
||||||
) { git ->
|
) { git ->
|
||||||
stageUntrackedFileUseCase(git)
|
|
||||||
stashChangesUseCase(git, null)
|
stashChangesUseCase(git, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue