fix: show date in timestamps; fix history divider appearing immediately
- MessagePane: show date in timestamps (Yesterday/MMM D) for messages not from today; divider now appears at the top of history on load rather than waiting for a live message to create the boundary - TUI: same date-aware timestamp formatting (Yesterday / Jan 2) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -383,7 +383,7 @@ func (m model) refreshViewport() model {
|
||||
w := m.vpContentWidth()
|
||||
var sb strings.Builder
|
||||
for _, e := range m.messages[room] {
|
||||
ts := styleMsgTime.Render(e.at.Format("15:04"))
|
||||
ts := styleMsgTime.Render(formatMsgTime(e.at))
|
||||
var from string
|
||||
if e.fromMe {
|
||||
from = styleMsgMe.Render(e.from)
|
||||
@@ -614,6 +614,17 @@ func filterIDs(ids []proto.PeerID, remove proto.PeerID) []proto.PeerID {
|
||||
return out
|
||||
}
|
||||
|
||||
func formatMsgTime(t time.Time) string {
|
||||
now := time.Now()
|
||||
if t.Year() == now.Year() && t.YearDay() == now.YearDay() {
|
||||
return t.Format("15:04")
|
||||
}
|
||||
if t.Year() == now.Year() && t.YearDay() == now.YearDay()-1 {
|
||||
return "Yesterday " + t.Format("15:04")
|
||||
}
|
||||
return t.Format("Jan 2 15:04")
|
||||
}
|
||||
|
||||
func min(a, b int) int {
|
||||
if a < b {
|
||||
return a
|
||||
|
||||
Reference in New Issue
Block a user