Skip to content

Commit

Permalink
Don't remove visited channels but mark them in a different color
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole Andre Birkedal committed Nov 30, 2019
1 parent 1b67c5e commit 7cdef3f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions ui/activity_bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ func NewActivityBar() *activityBar {
func (b *activityBar) updateActivityBar() {
list := []activityBuffer{}
for _, b := range b.buffers {
if !b.visited {
list = append(list, b)
}
list = append(list, b)
}

sort.SliceStable(list, func(i, j int) bool {
Expand All @@ -52,10 +50,18 @@ func bufferToBarElement(buffer activityBuffer) string {
return fmt.Sprintf("[-:blueviolet:-]%s[-:-:-] ", buffer.displayName)
}

func bufferToVisitedBarElement(buffer activityBuffer) string {
return fmt.Sprintf("[-:grey:-]%s[-:-:-] ", buffer.displayName)
}

func generateBar(buffers []activityBuffer) string {
var result string
for _, b := range buffers {
result += bufferToBarElement(b)
if !b.visited {
result += bufferToBarElement(b)
} else {
result += bufferToVisitedBarElement(b)
}
}

return result
Expand All @@ -68,6 +74,11 @@ func (b *activityBar) MarkAsVisited(buffer string, view *View) {
if ok {
elem.visited = true

// If you have buffers open with activity from 34 years ago
// then this is going to look weird! Not sure of a better way
// to keep the order than a translation down memory lane
elem.lastActivity = elem.lastActivity.AddDate(-34, 0, 0)

// Assign the value back to the map
b.buffers[buffer] = elem
}
Expand Down

0 comments on commit 7cdef3f

Please # to comment.