Selected branch is the first one always now

This commit is contained in:
Abdelilah El Aissaoui 2022-01-31 02:02:11 +01:00
parent 0f484a9b26
commit 2354602e6d

View File

@ -23,10 +23,19 @@ class BranchesViewModel @Inject constructor(
get() = _currentBranch
suspend fun loadBranches(git: Git) {
_currentBranch.value = branchesManager.currentBranchRef(git)?.name ?: ""
val branchesList = branchesManager.getBranches(git)
// set selected branch as the first one always
val selectedBranch = branchesList.find { it.name == _currentBranch.value }
if(selectedBranch != null) {
branchesList.remove(selectedBranch)
branchesList.add(0, selectedBranch)
}
_branches.value = branchesList
_currentBranch.value = branchesManager.currentBranchRef(git)?.name ?: ""
}
fun createBranch(branchName: String) = tabState.safeProcessing { git ->