diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-26 15:52:35 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-27 18:16:16 +1100 |
commit | 0dfb7c08b75659e161ad8fe69ea20aff7b259703 (patch) | |
tree | 2d43751610844e49f6b642e91eedb2f0d72a0803 /pkg/gui/controllers.go | |
parent | f0a4dcfdc39dfb881522959c13b97744a9d12fea (diff) |
remove controllers struct
Diffstat (limited to 'pkg/gui/controllers.go')
-rw-r--r-- | pkg/gui/controllers.go | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index 9d55625ea..4987210c9 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -30,7 +30,7 @@ func (gui *Gui) resetControllers() { Bisect: helpers.NewBisectHelper(helperCommon, gui.git), Suggestions: helpers.NewSuggestionsHelper(helperCommon, model, gui.refreshSuggestions), Files: helpers.NewFilesHelper(helperCommon, gui.git, osCommand), - WorkingTree: helpers.NewWorkingTreeHelper(model), + WorkingTree: helpers.NewWorkingTreeHelper(helperCommon, gui.git, model), Tags: helpers.NewTagsHelper(helperCommon, gui.git), GPG: helpers.NewGpgHelper(helperCommon, gui.os, gui.git), MergeAndRebase: rebaseHelper, @@ -102,27 +102,22 @@ func (gui *Gui) resetControllers() { remoteBranchesController := controllers.NewRemoteBranchesController(common) - gui.Controllers = Controllers{ - Submodules: submodulesController, - Global: controllers.NewGlobalController(common), - Files: controllers.NewFilesController( - common, - gui.enterSubmodule, - setCommitMessage, - getSavedCommitMessage, - gui.switchToMerge, - ), - Tags: controllers.NewTagsController(common), - LocalCommits: controllers.NewLocalCommitsController(common, syncController.HandlePull), - Remotes: controllers.NewRemotesController( - common, - func(branches []*models.RemoteBranch) { gui.State.Model.RemoteBranches = branches }, - ), - Menu: controllers.NewMenuController(common), - Undo: controllers.NewUndoController(common), - Sync: syncController, - } - + menuController := controllers.NewMenuController(common) + localCommitsController := controllers.NewLocalCommitsController(common, syncController.HandlePull) + tagsController := controllers.NewTagsController(common) + filesController := controllers.NewFilesController( + common, + gui.enterSubmodule, + setCommitMessage, + getSavedCommitMessage, + gui.switchToMerge, + ) + remotesController := controllers.NewRemotesController( + common, + func(branches []*models.RemoteBranch) { gui.State.Model.RemoteBranches = branches }, + ) + undoController := controllers.NewUndoController(common) + globalController := controllers.NewGlobalController(common) branchesController := controllers.NewBranchesController(common) gitFlowController := controllers.NewGitFlowController(common) filesRemoveController := controllers.NewFilesRemoveController(common) @@ -160,18 +155,19 @@ func (gui *Gui) resetControllers() { controllers.AttachControllers(context, controllers.NewBasicCommitsController(common, context)) } + controllers.AttachControllers(gui.State.Contexts.Files, filesController, filesRemoveController) + controllers.AttachControllers(gui.State.Contexts.Tags, tagsController) + controllers.AttachControllers(gui.State.Contexts.Submodules, submodulesController) + controllers.AttachControllers(gui.State.Contexts.LocalCommits, localCommitsController, bisectController) controllers.AttachControllers(gui.State.Contexts.Branches, branchesController, gitFlowController) - controllers.AttachControllers(gui.State.Contexts.Files, gui.Controllers.Files, filesRemoveController) - controllers.AttachControllers(gui.State.Contexts.Tags, gui.Controllers.Tags) - controllers.AttachControllers(gui.State.Contexts.Submodules, gui.Controllers.Submodules) - controllers.AttachControllers(gui.State.Contexts.LocalCommits, gui.Controllers.LocalCommits, bisectController) + controllers.AttachControllers(gui.State.Contexts.LocalCommits, localCommitsController, bisectController) controllers.AttachControllers(gui.State.Contexts.CommitFiles, commitFilesController) - controllers.AttachControllers(gui.State.Contexts.Remotes, gui.Controllers.Remotes) + controllers.AttachControllers(gui.State.Contexts.Remotes, remotesController) controllers.AttachControllers(gui.State.Contexts.Stash, stashController) - controllers.AttachControllers(gui.State.Contexts.Menu, gui.Controllers.Menu) + controllers.AttachControllers(gui.State.Contexts.Menu, menuController) controllers.AttachControllers(gui.State.Contexts.CommitMessage, commitMessageController) controllers.AttachControllers(gui.State.Contexts.RemoteBranches, remoteBranchesController) - controllers.AttachControllers(gui.State.Contexts.Global, gui.Controllers.Sync, gui.Controllers.Undo, gui.Controllers.Global) + controllers.AttachControllers(gui.State.Contexts.Global, syncController, undoController, globalController) // this must come last so that we've got our click handlers defined against the context listControllerFactory := controllers.NewListControllerFactory(gui.c) |