dbus: Smaller GetMessages buffers, avoid encoding attachment paths.
This commit is contained in:
@@ -44,11 +44,11 @@ public class AttachmentInfo : Object {
|
||||
}
|
||||
|
||||
public class Attachment : Object {
|
||||
public string guid;
|
||||
public string path;
|
||||
public string preview_path;
|
||||
public bool downloaded;
|
||||
public bool preview_downloaded;
|
||||
public string guid = "";
|
||||
public string path = "";
|
||||
public string preview_path = "";
|
||||
public bool downloaded = false;
|
||||
public bool preview_downloaded = false;
|
||||
public AttachmentMetadata? metadata;
|
||||
|
||||
public Attachment(string guid, AttachmentMetadata? metadata) {
|
||||
|
||||
@@ -73,14 +73,13 @@
|
||||
'sender' (string): Sender display name
|
||||
'attachments' (array of dictionaries): List of attachments
|
||||
'guid' (string): Attachment GUID
|
||||
'path' (string): Attachment path
|
||||
'preview_path' (string): Preview attachment path
|
||||
'downloaded' (boolean): Whether the attachment is downloaded
|
||||
'preview_downloaded' (boolean): Whether the preview is downloaded
|
||||
'metadata' (dictionary, optional): Attachment metadata
|
||||
'attribution_info' (dictionary, optional): Attribution info
|
||||
'width' (int32, optional): Width
|
||||
'height' (int32, optional): Height"/>
|
||||
'height' (int32, optional): Height
|
||||
Use GetAttachmentInfo for full/preview paths."/>
|
||||
</arg>
|
||||
</method>
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user