Private
Public Access
1
0

show dates in transcript

This commit is contained in:
2025-05-03 22:41:51 -07:00
parent 21c926456d
commit d3dfffd652
5 changed files with 74 additions and 13 deletions

View File

@@ -53,8 +53,8 @@ private class MessageDrawingArea : Widget
var container_width = get_width();
float y_offset = 0;
_chat_items.foreach((chat_item) => {
var message_width = chat_item.get_width();
var message_height = chat_item.get_height();
var item_width = chat_item.get_width();
var item_height = chat_item.get_height();
snapshot.save();
@@ -63,17 +63,17 @@ private class MessageDrawingArea : Widget
// Translate to the correct position
snapshot.translate(Graphene.Point() {
x = (chat_item.from_me ? (container_width - message_width - bubble_margin) : bubble_margin),
x = (chat_item.from_me ? (container_width - item_width - bubble_margin) : bubble_margin),
y = y_offset
});
// Undo the y-axis flip, origin is top left
snapshot.translate(Graphene.Point() { x = 0, y = -message_height });
snapshot.translate(Graphene.Point() { x = 0, y = -item_height });
chat_item.draw(snapshot);
snapshot.restore();
y_offset -= message_height + bubble_padding;
y_offset -= item_height + bubble_padding;
return true;
});
@@ -85,12 +85,24 @@ private class MessageDrawingArea : Widget
_chat_items.clear();
var sorted_messages = _messages
.order_by((a, b) => (int)b.date - (int)a.date); // reverse order
var reversed_messages = _messages
.order_by((a, b) => b.date.compare(a.date)); // reverse order
DateTime? last_date = null;
reversed_messages.foreach((message) => {
// Remember everything in here is backwards.
if (last_date == null) {
last_date = message.date;
} else if (last_date.difference(message.date) > (TimeSpan.MINUTE * 25)) {
var date_item = new DateItemLayout(last_date.to_local().format("%b %d, %Y at %H:%M"), this, max_width);
_chat_items.add(date_item);
last_date = message.date;
}
var text_bubble = new TextBubbleLayout(message, this, max_width);
_chat_items.add(text_bubble);
sorted_messages.foreach((message) => {
_chat_items.add(new TextBubbleLayout(message, this, max_width));
return true;
});