Private
Public Access
1
0

gtk: fix attachment download race condition

This commit is contained in:
2026-02-22 00:36:15 -08:00
parent 69892a4d08
commit 60020371b1
2 changed files with 12 additions and 6 deletions

View File

@@ -327,8 +327,8 @@ private class TranscriptDrawingArea : Widget
private void recompute_message_layouts() {
var container_width = get_width();
float max_width = container_width * 0.90f;
float image_max_width = max_width * 0.75f;
float max_width = container_width * 0.80f;
float image_max_width = max_width * 0.70f;
DateTime? last_date = null;
string? last_sender = null;

View File

@@ -159,7 +159,6 @@ public class TranscriptView : Adw.Bin
}
delegate void OpenPath(string path);
private ulong attachment_downloaded_handler_id = 0;
private void open_attachment(string attachment_guid) {
OpenPath open_path = (path) => {
try {
@@ -180,10 +179,17 @@ public class TranscriptView : Adw.Bin
// TODO: Should probably indicate progress here.
attachment_downloaded_handler_id = Repository.get_instance().attachment_downloaded.connect((guid) => {
ulong handler_id = 0;
handler_id = Repository.get_instance().attachment_downloaded.connect((guid) => {
if (guid == attachment_guid) {
open_path(attachment_info.path);
Repository.get_instance().disconnect(attachment_downloaded_handler_id);
try {
var updated_attachment_info = Repository.get_instance().get_attachment_info(attachment_guid);
open_path(updated_attachment_info.path);
} catch (GLib.Error e) {
warning("Failed to get attachment info after download: %s", e.message);
}
Repository.get_instance().disconnect(handler_id);
}
});
}