diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-26 17:03:30 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-26 17:22:42 +1100 |
commit | 077b6eb8a34f28d9d11c43b65d4b2a54835b0f31 (patch) | |
tree | 68ae6acf80cdfc0e60bc3df943a22f0d15cdbbe2 /pkg/gui/controllers.go | |
parent | 45dab51214d7deca689279a6a162d80ee27befc8 (diff) |
refactor to make code clearer
Diffstat (limited to 'pkg/gui/controllers.go')
-rw-r--r-- | pkg/gui/controllers.go | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index 13a0eedb5..b0f100f2f 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -129,41 +129,35 @@ func (gui *Gui) resetControllers() { stashController := controllers.NewStashController(common) commitFilesController := controllers.NewCommitFilesController(common) - switchToSubCommitsControllerFactory := controllers.NewSubCommitsSwitchControllerFactory( - common, - func(commits []*models.Commit) { gui.State.Model.SubCommits = commits }, - ) + setSubCommits := func(commits []*models.Commit) { gui.State.Model.SubCommits = commits } for _, context := range []controllers.ContextWithRefName{ gui.State.Contexts.Branches, gui.State.Contexts.RemoteBranches, gui.State.Contexts.Tags, } { - controllers.AttachControllers(context, switchToSubCommitsControllerFactory.Create(context)) + controllers.AttachControllers(context, controllers.NewSwitchToSubCommitsController( + common, setSubCommits, context, + )) } - commitishControllerFactory := controllers.NewCommitishControllerFactory( - common, - gui.SwitchToCommitFilesContext, - ) - - for _, context := range []controllers.Commitish{ + for _, context := range []controllers.CanSwitchToDiffFiles{ gui.State.Contexts.LocalCommits, gui.State.Contexts.ReflogCommits, gui.State.Contexts.SubCommits, gui.State.Contexts.Stash, } { - controllers.AttachControllers(context, commitishControllerFactory.Create(context)) + controllers.AttachControllers(context, controllers.NewSwitchToDiffFilesController( + common, gui.SwitchToCommitFilesContext, context, + )) } - basicCommitsControllerFactory := controllers.NewBasicCommitsControllerFactory(common) - for _, context := range []controllers.ContainsCommits{ gui.State.Contexts.LocalCommits, gui.State.Contexts.ReflogCommits, gui.State.Contexts.SubCommits, } { - controllers.AttachControllers(context, basicCommitsControllerFactory.Create(context)) + controllers.AttachControllers(context, controllers.NewBasicCommitsController(common, context)) } controllers.AttachControllers(gui.State.Contexts.Branches, branchesController, gitFlowController) |