From b491e7b88de6ce04d383a93c439b77cc733bb148 Mon Sep 17 00:00:00 2001 From: Jeremy O'Brien Date: Sat, 4 Apr 2020 13:54:09 -0400 Subject: [PATCH] exotui: always push tag names onto the stack when changing tags (even if tag is deleted as we switch) --- cmd/exotui/exotui.go | 11 ++++------- db/state.go | 7 ++----- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/cmd/exotui/exotui.go b/cmd/exotui/exotui.go index cf6ebb2..788ab48 100755 --- a/cmd/exotui/exotui.go +++ b/cmd/exotui/exotui.go @@ -100,13 +100,10 @@ func (s *state) Refresh() { func (s *state) SwitchTag(tag db.Tag) { if tag.ID != s.CurrentDBTag.ID { - deleted, err := s.DeleteTagIfEmpty(s.CurrentDBTag.ID) + err := s.DeleteTagIfEmpty(s.CurrentDBTag.ID) checkErr(err) - // if we're switching to a new tag, and this tag didn't just get wiped, - // push it onto our tag stack - if !deleted { - s.tagStack = append(s.tagStack, s.CurrentDBTag.Name) - } + // if we're switching to a new tag, push it onto our tag stack + s.tagStack = append(s.tagStack, s.CurrentDBTag.Name) } s.CurrentDBTag = tag @@ -128,7 +125,7 @@ func (s *state) PopTag() { // have to do the manual tag switch dance since SwitchTag() will push onto the tag stack if tag.ID != s.CurrentDBTag.ID { - _, err := s.DeleteTagIfEmpty(s.CurrentDBTag.ID) + err := s.DeleteTagIfEmpty(s.CurrentDBTag.ID) checkErr(err) } diff --git a/db/state.go b/db/state.go index eae7dd7..0dc40de 100644 --- a/db/state.go +++ b/db/state.go @@ -44,13 +44,11 @@ End: return err } -func (s *State) DeleteTagIfEmpty(id int64) (bool, error) { +func (s *State) DeleteTagIfEmpty(id int64) error { var rows []Row var refs Refs var err error - deleted := false - rows, err = s.DB.GetRowsForTagID(id) if err != nil { goto End @@ -63,9 +61,8 @@ func (s *State) DeleteTagIfEmpty(id int64) (bool, error) { if len(rows)+len(refs) == 0 { err = s.DB.DeleteTagByID(id) - deleted = true } End: - return deleted, err + return err }