this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

ui: show date when prev message is a different day

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>

+28 -3
+27 -2
src/App.zig
··· 1639 1639 var y_off: usize = message_list_win.height -| 1; 1640 1640 while (i > 0) { 1641 1641 i -= 1; 1642 - const message = channel.messages.items[i]; 1642 + var message = channel.messages.items[i]; 1643 1643 // syntax: <target> <message> 1644 1644 1645 1645 const sender: []const u8 = blk: { ··· 1744 1744 }); 1745 1745 1746 1746 if (message.time_buf) |buf| { 1747 + var date: bool = false; 1748 + if (i != 0 and channel.messages.items[i - 1].time != null) { 1749 + const time = message.time.?; 1750 + const prev = channel.messages.items[i - 1].time.?; 1751 + if (time.day != prev.day) { 1752 + date = true; 1753 + message.time_buf = try std.fmt.bufPrint( 1754 + message.time_buf.?, 1755 + "{d:0>2}/{d:0>2}", 1756 + .{ @intFromEnum(time.month), time.day }, 1757 + ); 1758 + } 1759 + } 1760 + if (i == 0) { 1761 + date = true; 1762 + message.time_buf = try std.fmt.bufPrint( 1763 + message.time_buf.?, 1764 + "{d:0>2}/{d:0>2}", 1765 + .{ @intFromEnum(message.time.?.month), message.time.?.day }, 1766 + ); 1767 + } 1768 + const fg: vaxis.Color = if (date) 1769 + .default 1770 + else 1771 + .{ .index = 8 }; 1747 1772 var time_seg = [_]vaxis.Segment{ 1748 1773 .{ 1749 1774 .text = buf, 1750 - .style = .{ .fg = .{ .index = 8 } }, 1775 + .style = .{ .fg = fg }, 1751 1776 }, 1752 1777 }; 1753 1778 _ = try gutter.print(&time_seg, .{});
+1 -1
src/irc.zig
··· 178 178 command: Command, 179 179 params: ?[]const u8, 180 180 time: ?zeit.Time = null, 181 - time_buf: ?[]const u8 = null, 181 + time_buf: ?[]u8 = null, 182 182 183 183 pub fn compareTime(_: void, lhs: Message, rhs: Message) bool { 184 184 const lhs_t = lhs.time orelse return false;