parent
a4570fc5ec
commit
ee82295c89
@ -85,17 +85,18 @@ class StatusViewModel @Inject constructor(
|
|||||||
_searchFilterUnstaged,
|
_searchFilterUnstaged,
|
||||||
) { state, showSearchStaged, filterStaged, showSearchUnstaged, filterUnstaged ->
|
) { state, showSearchStaged, filterStaged, showSearchUnstaged, filterUnstaged ->
|
||||||
if (state is StageState.Loaded) {
|
if (state is StageState.Loaded) {
|
||||||
|
|
||||||
val unstaged = if (showSearchUnstaged && filterUnstaged.text.isNotBlank()) {
|
val unstaged = if (showSearchUnstaged && filterUnstaged.text.isNotBlank()) {
|
||||||
state.unstaged.filter { it.filePath.lowercaseContains(filterUnstaged.text) }
|
state.unstaged.filter { it.filePath.lowercaseContains(filterUnstaged.text) }
|
||||||
} else {
|
} else {
|
||||||
state.unstaged
|
state.unstaged
|
||||||
}
|
}.prioritizeConflicts()
|
||||||
|
|
||||||
val staged = if (showSearchStaged && filterStaged.text.isNotBlank()) {
|
val staged = if (showSearchStaged && filterStaged.text.isNotBlank()) {
|
||||||
state.staged.filter { it.filePath.lowercaseContains(filterStaged.text) }
|
state.staged.filter { it.filePath.lowercaseContains(filterStaged.text) }
|
||||||
} else {
|
} else {
|
||||||
state.staged
|
state.staged
|
||||||
}
|
}.prioritizeConflicts()
|
||||||
|
|
||||||
state.copy(stagedFiltered = staged, unstagedFiltered = unstaged)
|
state.copy(stagedFiltered = staged, unstagedFiltered = unstaged)
|
||||||
|
|
||||||
@ -108,6 +109,21 @@ class StatusViewModel @Inject constructor(
|
|||||||
StageState.Loading
|
StageState.Loading
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun List<StatusEntry>.prioritizeConflicts(): List<StatusEntry> {
|
||||||
|
return this.groupBy { it.filePath }
|
||||||
|
.map {
|
||||||
|
val statusEntries = it.value
|
||||||
|
return@map if (statusEntries.count() == 1) {
|
||||||
|
statusEntries.first()
|
||||||
|
} else {
|
||||||
|
val conflictingEntry =
|
||||||
|
statusEntries.firstOrNull { entry -> entry.statusType == StatusType.CONFLICTING }
|
||||||
|
|
||||||
|
conflictingEntry ?: statusEntries.first()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var savedCommitMessage = CommitMessage("", MessageType.NORMAL)
|
var savedCommitMessage = CommitMessage("", MessageType.NORMAL)
|
||||||
|
|
||||||
var hasPreviousCommits = true // When false, disable "amend previous commit"
|
var hasPreviousCommits = true // When false, disable "amend previous commit"
|
||||||
@ -129,7 +145,8 @@ class StatusViewModel @Inject constructor(
|
|||||||
private val _isAmend = MutableStateFlow(false)
|
private val _isAmend = MutableStateFlow(false)
|
||||||
val isAmend: StateFlow<Boolean> = _isAmend
|
val isAmend: StateFlow<Boolean> = _isAmend
|
||||||
|
|
||||||
private val _isAmendRebaseInteractive = MutableStateFlow(true) // TODO should copy message from previous commit when this is required
|
private val _isAmendRebaseInteractive =
|
||||||
|
MutableStateFlow(true) // TODO should copy message from previous commit when this is required
|
||||||
val isAmendRebaseInteractive: StateFlow<Boolean> = _isAmendRebaseInteractive
|
val isAmendRebaseInteractive: StateFlow<Boolean> = _isAmendRebaseInteractive
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
Loading…
Reference in New Issue
Block a user