gtk: fix attachment download race condition
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user