Private
Public Access
1
0

dbus: Smaller GetMessages buffers, avoid encoding attachment paths.

This commit is contained in:
2026-02-21 22:22:09 -08:00
parent a52c2e0909
commit f38702bc95
9 changed files with 153 additions and 137 deletions

View File

@@ -363,6 +363,21 @@ private class TranscriptDrawingArea : Widget
// Check for attachments. For each one, add an image layout bubble
foreach (var attachment in message.attachments) {
string preview_path = attachment.preview_path;
bool preview_downloaded = attachment.preview_downloaded;
if (preview_path == null || preview_path == "") {
try {
var attachment_info = Repository.get_instance().get_attachment_info(attachment.guid);
if (attachment_info.preview_path != null) {
preview_path = attachment_info.preview_path;
}
preview_downloaded = attachment_info.preview_downloaded == true;
} catch (GLib.Error e) {
warning("Failed to load attachment info for %s: %s", attachment.guid, e.message);
}
}
Graphene.Size? image_size = null;
if (attachment.metadata != null) {
image_size = Graphene.Size() {
@@ -371,7 +386,7 @@ private class TranscriptDrawingArea : Widget
};
}
var image_layout = new ImageBubbleLayout(attachment.preview_path, message.from_me, this, max_width, image_size);
var image_layout = new ImageBubbleLayout(preview_path, message.from_me, this, max_width, image_size);
image_layout.id = @"image-$(attachment.guid)";
image_layout.attachment_guid = attachment.guid;
@@ -379,12 +394,12 @@ private class TranscriptDrawingArea : Widget
start_animation(image_layout.id);
}
image_layout.is_downloaded = attachment.preview_downloaded;
image_layout.is_downloaded = preview_downloaded;
items.add(image_layout);
// If the attachment isn't downloaded, queue a download since we are going to be showing it here.
// TODO: Probably would be better if we only did this for stuff in the viewport.
if (!attachment.preview_downloaded) {
if (!preview_downloaded) {
try {
Repository.get_instance().download_attachment(attachment.guid, true);
} catch (GLib.Error e) {
@@ -447,4 +462,4 @@ public struct VisibleLayout {
this.bubble = bubble;
this.rect = rect;
}
}
}