From 464ea64d78e6b31d2ea70e70aa02bdb974bd2dc6 Mon Sep 17 00:00:00 2001 From: delthas Date: Tue, 16 Aug 2022 08:41:42 +0200 Subject: Show the message date instead of its time on date change Fixes: https://todo.sr.ht/~taiite/senpai/17 --- ui/buffers.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'ui/buffers.go') diff --git a/ui/buffers.go b/ui/buffers.go index b13465f..5e2691c 100644 --- a/ui/buffers.go +++ b/ui/buffers.go @@ -758,8 +758,19 @@ func (bs *BufferList) DrawTimeline(screen tcell.Screen, x0, y0, nickColWidth int } if yi >= y0 { - if i == 0 || b.lines[i-1].At.Truncate(time.Minute) != line.At.Truncate(time.Minute) { + var showDate bool + if i == 0 || yi == y0 { + showDate = true + } else { + yb, mb, dd := b.lines[i-1].At.Local().Date() + ya, ma, da := b.lines[i].At.Local().Date() + showDate = yb != ya || mb != ma || dd != da + } + if showDate { st := tcell.StyleDefault.Bold(true) + printDate(screen, x0, yi, st, line.At.Local()) + } else if b.lines[i-1].At.Truncate(time.Minute) != line.At.Truncate(time.Minute) { + st := tcell.StyleDefault.Foreground(tcell.ColorGray) printTime(screen, x0, yi, st, line.At.Local()) } -- cgit v1.2.3