Compare commits
2 Commits
69d3265b64
...
08a2027332
Author | SHA1 | Date | |
---|---|---|---|
08a2027332 | |||
b06e031ee0 |
@ -175,24 +175,14 @@ 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 := []timeCategory{
|
||||
categories := []struct {
|
||||
name string
|
||||
cutoff time.Duration
|
||||
}{
|
||||
{"Today", now.Sub(midnight)},
|
||||
{"Yesterday", now.Sub(midnight.AddDate(0, 0, -1))},
|
||||
{"This week", now.Sub(midnight.AddDate(0, 0, -dayOfWeek))},
|
||||
@ -209,7 +199,7 @@ func (m *conversationsModel) renderConversationList() string {
|
||||
|
||||
categoryStyle := lipgloss.NewStyle().
|
||||
MarginBottom(1).
|
||||
Foreground(lipgloss.Color("170")).
|
||||
Foreground(lipgloss.Color("12")).
|
||||
PaddingLeft(1).
|
||||
Bold(true)
|
||||
|
||||
@ -221,12 +211,16 @@ func (m *conversationsModel) renderConversationList() string {
|
||||
untitledStyle := lipgloss.NewStyle().Faint(true).Italic(true)
|
||||
selectedStyle := lipgloss.NewStyle().Faint(true).Foreground(lipgloss.Color("6"))
|
||||
|
||||
var currentOffset int
|
||||
var currentCategory string
|
||||
var (
|
||||
currentOffset int
|
||||
currentCategory string
|
||||
sb strings.Builder
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
@ -248,7 +242,6 @@ func (m *conversationsModel) renderConversationList() string {
|
||||
}
|
||||
|
||||
tStyle := titleStyle.Copy()
|
||||
padding := " "
|
||||
if c.conv.Title == "" {
|
||||
tStyle = tStyle.Inherit(untitledStyle).SetString("(untitled)")
|
||||
}
|
||||
@ -263,9 +256,9 @@ func (m *conversationsModel) renderConversationList() string {
|
||||
|
||||
m.itemOffsets[i] = currentOffset
|
||||
item := itemStyle.Render(fmt.Sprintf(
|
||||
"%s\n%s",
|
||||
"%s\n %s",
|
||||
title,
|
||||
padding+ageStyle.Render(util.HumanTimeElapsedSince(lastReplyAge)),
|
||||
ageStyle.Render(util.HumanTimeElapsedSince(lastReplyAge)),
|
||||
))
|
||||
sb.WriteString(item)
|
||||
currentOffset += height(item)
|
||||
|
Loading…
Reference in New Issue
Block a user