MCPcopy Create free account
hub / github.com/basecamp/hey-cli / orderBoxes

Function orderBoxes

internal/tui/nav.go:75–96  ·  view source on GitHub ↗

orderBoxes sorts boxes by the preferred order. Known boxes appear first in their predefined order; unknown boxes are appended at the end.

(boxes []models.Box)

Source from the content-addressed store, hash-verified

73 {"Set Aside", "5"},
74 {"Bubble up", "6"},
75}
76
77// orderBoxes sorts boxes by the preferred order. Known boxes appear first
78// in their predefined order; unknown boxes are appended at the end.
79func orderBoxes(boxes []mail.Source) []mail.Source {
80 ordered := make([]mail.Source, 0, len(boxes))
81 type sourceKey struct {
82 id int64
83 kind mail.Kind
84 }
85 used := make(map[sourceKey]bool)
86
87 // Add known boxes in preferred order
88 for _, spec := range knownBoxes {
89 for _, b := range boxes {
90 key := sourceKey{id: b.ID, kind: b.Kind}
91 if !isOrganizedMailSource(b.Kind) && strings.EqualFold(b.Name, spec.name) && !used[key] {
92 ordered = append(ordered, b)
93 used[key] = true
94 break
95 }
96 }
97 }
98 // Append any remaining boxes
99 for _, b := range boxes {

Callers 3

TestOrderBoxesFunction · 0.85
UpdateMethod · 0.85
mailWithPostingsFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestOrderBoxesFunction · 0.68
mailWithPostingsFunction · 0.68