Private
Public Access
1
0

gtk: implement get_attachment_fd and texture/attachment cache, viewport loading

This commit is contained in:
2026-02-21 23:28:21 -08:00
parent f0ec6b8cb4
commit 7cf2724a75
5 changed files with 145 additions and 84 deletions

View File

@@ -363,49 +363,23 @@ 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) {
if (attachment.metadata != null && attachment.metadata.attribution_info != null) {
image_size = Graphene.Size() {
width = attachment.metadata.attribution_info.width,
height = attachment.metadata.attribution_info.height
};
}
var image_layout = new ImageBubbleLayout(preview_path, message.from_me, this, max_width, image_size);
var image_layout = new ImageBubbleLayout(attachment.guid, message.from_me, this, max_width, image_size);
image_layout.id = @"image-$(attachment.guid)";
image_layout.attachment_guid = attachment.guid;
if (animate) {
start_animation(image_layout.id);
}
image_layout.is_downloaded = preview_downloaded;
image_layout.is_downloaded = attachment.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 (!preview_downloaded) {
try {
Repository.get_instance().download_attachment(attachment.guid, true);
} catch (GLib.Error e) {
warning("Wasn't able to message daemon about queuing attachment download: %s", e.message);
}
}
}
last_sender = message.sender;