Skip to content

Commit ed0cc8b

Browse files
authored
Some code cleanup (#4449)
- **PR Description** Two cleanup commits.
2 parents 9c98fd8 + 8ba57b6 commit ed0cc8b

36 files changed

+36
-111
lines changed

pkg/gui/context.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,7 @@ func (self *ContextMgr) Replace(c types.Context) {
5555
self.Activate(c, types.OnFocusOpts{})
5656
}
5757

58-
func (self *ContextMgr) Push(c types.Context, opts ...types.OnFocusOpts) {
59-
if len(opts) > 1 {
60-
panic("cannot pass multiple opts to Push")
61-
}
62-
63-
singleOpts := types.OnFocusOpts{}
64-
if len(opts) > 0 {
65-
// using triple dot but you should only ever pass one of these opt structs
66-
singleOpts = opts[0]
67-
}
68-
58+
func (self *ContextMgr) Push(c types.Context, opts types.OnFocusOpts) {
6959
if !c.IsFocusable() {
7060
return
7161
}
@@ -77,7 +67,7 @@ func (self *ContextMgr) Push(c types.Context, opts ...types.OnFocusOpts) {
7767
}
7868

7969
if contextToActivate != nil {
80-
self.Activate(contextToActivate, singleOpts)
70+
self.Activate(contextToActivate, opts)
8171
}
8272
}
8373

pkg/gui/controllers/custom_patch_options_menu_action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error {
213213
if err := self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err); err != nil {
214214
return err
215215
}
216-
self.c.Context().Push(self.c.Contexts().LocalCommits)
216+
self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{})
217217
return nil
218218
})
219219
},

pkg/gui/controllers/filtering_menu_action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (self *FilteringMenuAction) setFiltering() error {
120120
repoState.SetScreenMode(types.SCREEN_HALF)
121121
}
122122

123-
self.c.Context().Push(self.c.Contexts().LocalCommits)
123+
self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{})
124124

125125
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() error {
126126
self.c.Contexts().LocalCommits.SetSelection(0)

pkg/gui/controllers/helpers/commits_helper.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ import (
1212
"github.com/samber/lo"
1313
)
1414

15-
type ICommitsHelper interface {
16-
UpdateCommitPanelView(message string)
17-
}
18-
1915
type CommitsHelper struct {
2016
c *HelperCommon
2117

@@ -26,8 +22,6 @@ type CommitsHelper struct {
2622
setCommitDescription func(string)
2723
}
2824

29-
var _ ICommitsHelper = &CommitsHelper{}
30-
3125
func NewCommitsHelper(
3226
c *HelperCommon,
3327
getCommitSummary func() string,
@@ -150,7 +144,7 @@ func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOp
150144

151145
self.UpdateCommitPanelView(opts.InitialMessage)
152146

153-
self.c.Context().Push(self.c.Contexts().CommitMessage)
147+
self.c.Context().Push(self.c.Contexts().CommitMessage, types.OnFocusOpts{})
154148
}
155149

156150
func (self *CommitsHelper) OnCommitSuccess() {

pkg/gui/controllers/helpers/confirmation_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
177177

178178
self.c.State().GetRepoState().SetCurrentPopupOpts(&opts)
179179

180-
self.c.Context().Push(self.c.Contexts().Confirmation)
180+
self.c.Context().Push(self.c.Contexts().Confirmation, types.OnFocusOpts{})
181181
}
182182

183183
func (self *ConfirmationHelper) setKeyBindings(cancel goContext.CancelFunc, opts types.CreatePopupPanelOpts) {

pkg/gui/controllers/helpers/files_helper.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ import (
66
"github.com/samber/lo"
77
)
88

9-
type IFilesHelper interface {
10-
EditFiles(filenames []string) error
11-
EditFileAtLine(filename string, lineNumber int) error
12-
OpenFile(filename string) error
13-
}
14-
159
type FilesHelper struct {
1610
c *HelperCommon
1711
}
@@ -22,8 +16,6 @@ func NewFilesHelper(c *HelperCommon) *FilesHelper {
2216
}
2317
}
2418

25-
var _ IFilesHelper = &FilesHelper{}
26-
2719
func (self *FilesHelper) EditFiles(filenames []string) error {
2820
absPaths := lo.Map(filenames, func(filename string, _ int) string {
2921
absPath, err := filepath.Abs(filename)

pkg/gui/controllers/helpers/fixup_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error {
137137
}
138138

139139
self.c.Contexts().LocalCommits.SetSelection(index)
140-
self.c.Context().Push(self.c.Contexts().LocalCommits)
140+
self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{})
141141
return nil
142142
}
143143

pkg/gui/controllers/helpers/host_helper.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ import (
66

77
// this helper just wraps our hosting_service package
88

9-
type IHostHelper interface {
10-
GetPullRequestURL(from string, to string) (string, error)
11-
GetCommitURL(commitHash string) (string, error)
12-
}
13-
149
type HostHelper struct {
1510
c *HelperCommon
1611
}

pkg/gui/controllers/helpers/merge_and_rebase_helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (self *MergeAndRebaseHelper) PromptForConflictHandling() error {
206206
{
207207
Label: self.c.Tr.ViewConflictsMenuItem,
208208
OnPress: func() error {
209-
self.c.Context().Push(self.c.Contexts().Files)
209+
self.c.Context().Push(self.c.Contexts().Files, types.OnFocusOpts{})
210210
return nil
211211
},
212212
},
@@ -357,7 +357,7 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error {
357357
if err = self.ResetMarkedBaseCommit(); err != nil {
358358
return err
359359
}
360-
self.c.Context().Push(self.c.Contexts().LocalCommits)
360+
self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{})
361361
return nil
362362
},
363363
},

pkg/gui/controllers/helpers/merge_conflicts_helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (self *MergeConflictsHelper) EscapeMerge() error {
6262
// files context over it.
6363
// So long as both places call OnUIThread, we're fine.
6464
if self.c.Context().IsCurrent(self.c.Contexts().MergeConflicts) {
65-
self.c.Context().Push(self.c.Contexts().Files)
65+
self.c.Context().Push(self.c.Contexts().Files, types.OnFocusOpts{})
6666
}
6767
return nil
6868
})
@@ -93,7 +93,7 @@ func (self *MergeConflictsHelper) SwitchToMerge(path string) error {
9393
}
9494
}
9595

96-
self.c.Context().Push(self.c.Contexts().MergeConflicts)
96+
self.c.Context().Push(self.c.Contexts().MergeConflicts, types.OnFocusOpts{})
9797
return nil
9898
}
9999

0 commit comments

Comments
 (0)