mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
Add pretty timestamp to rooms in RosterView
This commit is contained in:
parent
32665a2e5a
commit
2a01fdb559
1 changed files with 14 additions and 6 deletions
|
@ -139,12 +139,20 @@ func (rstr *RosterView) Draw(screen mauview.Screen) {
|
|||
Background(rstr.selectedBackgroundColor)
|
||||
}
|
||||
|
||||
widget.WriteLinePadded(
|
||||
screen, mauview.AlignCenter,
|
||||
room.GetTitle(),
|
||||
2, y, rstr.width,
|
||||
style,
|
||||
)
|
||||
timestamp := room.LastReceivedMessage
|
||||
day, _ := time.ParseDuration("24h")
|
||||
tm := timestamp.Format("15:04")
|
||||
if timestamp.Before(time.Now().Round(day)) {
|
||||
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
|
||||
if y >= rstr.height {
|
||||
|
|
Loading…
Add table
Reference in a new issue