forked from Mirrors/gomuks
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)
|
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 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue