1
0
Fork 0
forked from Mirrors/gomuks

Add pretty timestamp to rooms in RosterView

This commit is contained in:
FIGBERT 2023-02-27 00:19:17 -08:00
parent 32665a2e5a
commit 2a01fdb559
No known key found for this signature in database
GPG key ID: 67F1598D607A844B

View file

@ -139,12 +139,20 @@ func (rstr *RosterView) Draw(screen mauview.Screen) {
Background(rstr.selectedBackgroundColor) Background(rstr.selectedBackgroundColor)
} }
widget.WriteLinePadded( timestamp := room.LastReceivedMessage
screen, mauview.AlignCenter, day, _ := time.ParseDuration("24h")
room.GetTitle(), tm := timestamp.Format("15:04")
2, y, rstr.width, if timestamp.Before(time.Now().Round(day)) {
style, if timestamp.Before(time.Now().Round(day).AddDate(0, 0, -7)) {
) tm = timestamp.Format("2006-01-02")
} else {
tm = timestamp.Format("Monday")
}
}
tmX := rstr.width - 3 - len(tm)
widget.WriteLine(screen, mauview.AlignLeft, room.GetTitle(), 2, y, tmX, style)
widget.WriteLine(screen, mauview.AlignLeft, tm, tmX, y, 2+len(tm), style)
y += renderHeight y += renderHeight
if y >= rstr.height { if y >= rstr.height {