fix: crash when no groups defined and opening the group panel

This commit is contained in:
Slug-Boi
2024-11-25 22:17:07 +01:00
parent 9224da930f
commit a9850510e3
+8
View File
@@ -89,6 +89,10 @@ func newModel() mainModel {
p.PerPage = cap * lines
p.SetTotalPages(len(content))
if len(content) == 0 {
content = append(content, "No groups found")
}
m := mainModel{content: content, paginator: p}
return m
}
@@ -138,7 +142,11 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
// Adrian is a fucking genius thanks for the idea :)
if m.index == 0 {
m.paginator.Page = 0
} else {
m.paginator.Page = m.index / (cap * lines)
}
cmds = append(cmds, cmd)
return m, tea.Batch(cmds...)