Private
Public Access
1
0

Implements attachments display in transcript

This commit is contained in:
2025-06-06 20:03:02 -07:00
parent 1a2dad08a5
commit 54790d1d70
9 changed files with 252 additions and 31 deletions

View File

@@ -44,6 +44,7 @@ public class TranscriptView : Adw.Bin
private TranscriptDrawingArea transcript_drawing_area = new TranscriptDrawingArea();
private ScrolledWindow scrolled_window = new ScrolledWindow();
private ulong messages_changed_handler_id = 0;
private bool needs_reload = false;
public TranscriptView() {
container = new Adw.ToolbarView();
@@ -56,6 +57,36 @@ public class TranscriptView : Adw.Bin
var header_bar = new Adw.HeaderBar();
header_bar.set_title_widget(title_label);
container.add_top_bar(header_bar);
Repository.get_instance().attachment_downloaded.connect((attachment_guid) => {
debug("Attachment downloaded: %s", attachment_guid);
// See if this attachment is part of this transcript.
bool contains_attachment = false;
foreach (var message in _model.messages) {
foreach (var attachment in message.attachments) {
if (attachment.guid == attachment_guid) {
contains_attachment = true;
break;
}
}
}
if (contains_attachment && !needs_reload) {
debug("Queueing reload of messages for attachment download");
needs_reload = true;
GLib.Idle.add(() => {
if (needs_reload) {
debug("Reloading messages for attachment download");
model.load_messages();
needs_reload = false;
}
return false;
}, GLib.Priority.HIGH);
}
});
}
private void reload_messages() {