mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 12:45:47 +00:00
fix: crash when no groups defined and opening the group panel
This commit is contained in:
@@ -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...)
|
||||
|
||||
Reference in New Issue
Block a user