diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-05-28 08:32:00 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-05-29 13:46:53 +0200 |
commit | 35af886f554c85d978213fa3f7c735dc25d651ac (patch) | |
tree | dafdf18e3928d1cd6e6d9b50efbfb17c0ba1edf2 /pkg | |
parent | f45ecbc19ac8c5dd4772ebe87f9c06f533e4feba (diff) |
Refresh branches and reflog independently when sorting branches by date
When branches are sorted by recency we have this logic that first loads the
branches so that they can be rendered quickly; in parallel, it starts loading
the reflog in the background, and when that's done, it loads the branches again
so that they get their recency values. This means that branches are loaded twice
at startup.
We don't need this logic when branches are not sorted by recency, so we can
simply load branches and reflog in parallel like everything else.
This shouldn't change any user observable behavior, it just avoids doing
unnecessary work at startup.
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/controllers/helpers/refresh_helper.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 8d88faeec..b927296fc 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -127,7 +127,12 @@ func (self *RefreshHelper) Refresh(options types.RefreshOptions) error { refresh("commits and commit files", self.refreshCommitsAndCommitFiles) includeWorktreesWithBranches = scopeSet.Includes(types.WORKTREES) - refresh("reflog and branches", func() { self.refreshReflogAndBranches(includeWorktreesWithBranches, options.KeepBranchSelectionIndex) }) + if self.c.AppState.LocalBranchSortOrder == "recency" { + refresh("reflog and branches", func() { self.refreshReflogAndBranches(includeWorktreesWithBranches, options.KeepBranchSelectionIndex) }) + } else { + refresh("branches", func() { self.refreshBranches(includeWorktreesWithBranches, options.KeepBranchSelectionIndex) }) + refresh("reflog", func() { _ = self.refreshReflogCommits() }) + } } else if scopeSet.Includes(types.REBASE_COMMITS) { // the above block handles rebase commits so we only need to call this one // if we've asked specifically for rebase commits and not those other things |