From e392b9f86ab7683b231de4c1addd1986cffc9d91 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 20 Mar 2022 09:24:39 +1100 Subject: no more filterThenMap --- pkg/gui/context.go | 15 +++++++-------- pkg/gui/controllers/helpers/cherry_pick_helper.go | 13 ++++++------- 2 files changed, 13 insertions(+), 15 deletions(-) (limited to 'pkg') diff --git a/pkg/gui/context.go b/pkg/gui/context.go index 75e2a7357..e75eb0a05 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -14,14 +14,13 @@ import ( ) func (gui *Gui) popupViewNames() []string { - return slices.FilterThenMap(gui.State.Contexts.Flatten(), - func(c types.Context) bool { - return c.GetKind() == types.PERSISTENT_POPUP || c.GetKind() == types.TEMPORARY_POPUP - }, - func(c types.Context) string { - return c.GetViewName() - }, - ) + popups := slices.Filter(gui.State.Contexts.Flatten(), func(c types.Context) bool { + return c.GetKind() == types.PERSISTENT_POPUP || c.GetKind() == types.TEMPORARY_POPUP + }) + + return slices.Map(popups, func(c types.Context) string { + return c.GetViewName() + }) } func (gui *Gui) currentContextKeyIgnoringPopups() types.ContextKey { diff --git a/pkg/gui/controllers/helpers/cherry_pick_helper.go b/pkg/gui/controllers/helpers/cherry_pick_helper.go index 9117f24f6..2c9ca301a 100644 --- a/pkg/gui/controllers/helpers/cherry_pick_helper.go +++ b/pkg/gui/controllers/helpers/cherry_pick_helper.go @@ -118,14 +118,13 @@ func (self *CherryPickHelper) add(selectedCommit *models.Commit, commitsList []* commitSet := self.CherryPickedCommitShaSet() commitSet.Add(selectedCommit.Sha) - newCommits := slices.FilterThenMap(commitsList, - func(commit *models.Commit) bool { return commitSet.Includes(commit.Sha) }, - func(commit *models.Commit) *models.Commit { - return &models.Commit{Name: commit.Name, Sha: commit.Sha} - }, - ) + cherryPickedCommits := slices.Filter(commitsList, func(commit *models.Commit) bool { + return commitSet.Includes(commit.Sha) + }) - self.getData().CherryPickedCommits = newCommits + self.getData().CherryPickedCommits = slices.Map(cherryPickedCommits, func(commit *models.Commit) *models.Commit { + return &models.Commit{Name: commit.Name, Sha: commit.Sha} + }) } // you can only copy from one context at a time, because the order and position of commits matter -- cgit v1.2.3