diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-02-05 17:04:10 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-17 19:13:40 +1100 |
commit | d82f175e79f18756769d91de94458b095130297c (patch) | |
tree | 63c0c5b17a698a5a202a85b930edd0cf9e85ebf7 /pkg/gui/reflog_panel.go | |
parent | 145c69d9ae32ec8fbdd6d1e6116efec466a0a709 (diff) |
refactor contexts
Diffstat (limited to 'pkg/gui/reflog_panel.go')
-rw-r--r-- | pkg/gui/reflog_panel.go | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go index d3569ee81..57b4e0a35 100644 --- a/pkg/gui/reflog_panel.go +++ b/pkg/gui/reflog_panel.go @@ -9,17 +9,11 @@ import ( // list panel functions func (gui *Gui) getSelectedReflogCommit() *models.Commit { - selectedLine := gui.State.Panels.ReflogCommits.SelectedLineIdx - reflogComits := gui.State.Model.FilteredReflogCommits - if selectedLine == -1 || len(reflogComits) == 0 { - return nil - } - - return reflogComits[selectedLine] + return gui.State.Contexts.ReflogCommits.GetSelected() } func (gui *Gui) reflogCommitsRenderToMain() error { - commit := gui.getSelectedReflogCommit() + commit := gui.State.Contexts.ReflogCommits.GetSelected() var task updateTask if commit == nil { task = NewRenderStringTask("No reflog history") @@ -38,7 +32,7 @@ func (gui *Gui) reflogCommitsRenderToMain() error { } func (gui *Gui) CheckoutReflogCommit() error { - commit := gui.getSelectedReflogCommit() + commit := gui.State.Contexts.ReflogCommits.GetSelected() if commit == nil { return nil } @@ -55,19 +49,17 @@ func (gui *Gui) CheckoutReflogCommit() error { return err } - gui.State.Panels.ReflogCommits.SelectedLineIdx = 0 - return nil } func (gui *Gui) handleCreateReflogResetMenu() error { - commit := gui.getSelectedReflogCommit() + commit := gui.State.Contexts.ReflogCommits.GetSelected() return gui.helpers.Refs.CreateGitResetMenu(commit.Sha) } func (gui *Gui) handleViewReflogCommitFiles() error { - commit := gui.getSelectedReflogCommit() + commit := gui.State.Contexts.ReflogCommits.GetSelected() if commit == nil { return nil } @@ -81,7 +73,7 @@ func (gui *Gui) handleViewReflogCommitFiles() error { } func (gui *Gui) handleCopyReflogCommit() error { - commit := gui.getSelectedReflogCommit() + commit := gui.State.Contexts.ReflogCommits.GetSelected() if commit == nil { return nil } @@ -91,7 +83,7 @@ func (gui *Gui) handleCopyReflogCommit() error { func (gui *Gui) handleCopyReflogCommitRange() error { // just doing this to ensure something is selected - commit := gui.getSelectedReflogCommit() + commit := gui.State.Contexts.ReflogCommits.GetSelected() if commit == nil { return nil } |