Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
contact list now loops (#37)
Browse files Browse the repository at this point in the history
Co-authored-by: Derric Williams <wilzder@amazon.com>
  • Loading branch information
derricw and Derric Williams authored Feb 14, 2021
1 parent 2176688 commit 93fed9c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions widgets/contactlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ type ContactListPanel struct {
func (cl *ContactListPanel) Next() *model.Contact {
if cl.currentIndex < len(cl.sortedContacts)-1 {
cl.currentIndex++
} else {
cl.currentIndex = 0 // loop around
}
return cl.sortedContacts[cl.currentIndex]
}

func (cl *ContactListPanel) Previous() *model.Contact {
if cl.currentIndex > 0 {
cl.currentIndex--
} else {
cl.currentIndex = len(cl.sortedContacts) - 1 // loop around
}
return cl.sortedContacts[cl.currentIndex]
}
Expand Down

0 comments on commit 93fed9c

Please sign in to comment.