Compare commits

..

No commits in common. "08a202733244dc400a2e2d9ca0eb6df82404c522" and "69d3265b640b72164db150135e3f04384e37ec30" have entirely different histories.

View File

@ -175,14 +175,24 @@ func (m *conversationsModel) headerView() string {
}
func (m *conversationsModel) renderConversationList() string {
type timeCategory struct {
name string
cutoff time.Duration
}
type listItem struct {
id uint
short string
title string
elapsed string
lastReplyAge time.Duration
}
now := time.Now()
midnight := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
monthStart := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
dayOfWeek := int(now.Weekday())
categories := []struct {
name string
cutoff time.Duration
}{
categories := []timeCategory{
{"Today", now.Sub(midnight)},
{"Yesterday", now.Sub(midnight.AddDate(0, 0, -1))},
{"This week", now.Sub(midnight.AddDate(0, 0, -dayOfWeek))},
@ -199,7 +209,7 @@ func (m *conversationsModel) renderConversationList() string {
categoryStyle := lipgloss.NewStyle().
MarginBottom(1).
Foreground(lipgloss.Color("12")).
Foreground(lipgloss.Color("170")).
PaddingLeft(1).
Bold(true)
@ -211,16 +221,12 @@ func (m *conversationsModel) renderConversationList() string {
untitledStyle := lipgloss.NewStyle().Faint(true).Italic(true)
selectedStyle := lipgloss.NewStyle().Faint(true).Foreground(lipgloss.Color("6"))
var (
currentOffset int
currentCategory string
sb strings.Builder
)
var currentOffset int
var currentCategory string
m.itemOffsets = make([]int, len(m.conversations))
sb := &strings.Builder{}
sb.WriteRune('\n')
currentOffset += 1
for i, c := range m.conversations {
lastReplyAge := now.Sub(c.lastReply.CreatedAt)
@ -242,6 +248,7 @@ func (m *conversationsModel) renderConversationList() string {
}
tStyle := titleStyle.Copy()
padding := " "
if c.conv.Title == "" {
tStyle = tStyle.Inherit(untitledStyle).SetString("(untitled)")
}
@ -258,7 +265,7 @@ func (m *conversationsModel) renderConversationList() string {
item := itemStyle.Render(fmt.Sprintf(
"%s\n%s",
title,
ageStyle.Render(util.HumanTimeElapsedSince(lastReplyAge)),
padding+ageStyle.Render(util.HumanTimeElapsedSince(lastReplyAge)),
))
sb.WriteString(item)
currentOffset += height(item)