diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-08-05 11:19:16 +0200 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2023-08-29 08:16:40 +0200 |
commit | e8fac6ca7360faf5db1c82af2b2e9c87aa5a5edc (patch) | |
tree | ff9d9f469cf796f88bcd209f72005be2537cab1e /pkg/gui/controllers.go | |
parent | 4de3fadb00e3829bcda3ae2d4379251c6a81c0a8 (diff) |
Extract a SubCommitsHelper from SwitchToSubCommitsController
We want to use it from BranchesController too.
Diffstat (limited to 'pkg/gui/controllers.go')
-rw-r--r-- | pkg/gui/controllers.go | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index 1430ad239..40a482f30 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -76,6 +76,13 @@ func (gui *Gui) resetHelpersAndControllers() { helperCommon, func() *status.StatusManager { return gui.statusManager }, ) + + setSubCommits := func(commits []*models.Commit) { + gui.Mutexes.SubCommitsMutex.Lock() + defer gui.Mutexes.SubCommitsMutex.Unlock() + + gui.State.Model.SubCommits = commits + } gui.helpers = &helpers.Helpers{ Refs: refsHelper, Host: helpers.NewHostHelper(helperCommon), @@ -111,8 +118,9 @@ func (gui *Gui) resetHelpersAndControllers() { modeHelper, appStatusHelper, ), - Search: helpers.NewSearchHelper(helperCommon), - Worktree: worktreeHelper, + Search: helpers.NewSearchHelper(helperCommon), + Worktree: worktreeHelper, + SubCommits: helpers.NewSubCommitsHelper(helperCommon, refreshHelper, setSubCommits), } gui.CustomCommandsClient = custom_commands.NewClient( @@ -206,13 +214,6 @@ func (gui *Gui) resetHelpersAndControllers() { controllers.AttachControllers(context, sideWindowControllerFactory.Create(context)) } - setSubCommits := func(commits []*models.Commit) { - gui.Mutexes.SubCommitsMutex.Lock() - defer gui.Mutexes.SubCommitsMutex.Unlock() - - gui.State.Model.SubCommits = commits - } - for _, context := range []controllers.CanSwitchToSubCommits{ gui.State.Contexts.Branches, gui.State.Contexts.RemoteBranches, @@ -220,7 +221,7 @@ func (gui *Gui) resetHelpersAndControllers() { gui.State.Contexts.ReflogCommits, } { controllers.AttachControllers(context, controllers.NewSwitchToSubCommitsController( - common, setSubCommits, context, + common, context, )) } |