@@ -5,12 +5,15 @@ namespace Dc {
55 public Gtk . Revealer revealer { get ; private set ; }
66
77 private unowned Window ? window = null ;
8+ private unowned RpcClient ? rpc = null ;
89 private Gtk . Box bar_content;
910 private int [] msg_ids = {};
1011 private int current_chat_id = 0 ;
1112 private unowned GLib . ListStore message_store;
1213 private unowned SettingsManager settings;
1314
15+ public string ? self_email { get ; set ; default = null ; }
16+
1417 public PinnedMessagesManager (GLib .ListStore message_store ,
1518 SettingsManager settings ) {
1619 this . message_store = message_store;
@@ -25,6 +28,7 @@ namespace Dc {
2528 }
2629
2730 public void set_window (Window w ) { this . window = w; }
31+ public void set_rpc (RpcClient r ) { this . rpc = r; }
2832
2933 public void load_for_chat (int chat_id ) {
3034 current_chat_id = chat_id;
@@ -68,10 +72,10 @@ namespace Dc {
6872 m. is_pinned = is_pinned (msg_id);
6973 refresh_in_store (msg_id);
7074 }
71- update_bar ();
75+ update_bar. begin ();
7276 }
7377
74- public void update_bar () {
78+ public async void update_bar () {
7579 /* Clear existing pinned entries */
7680 Gtk . Widget ? child;
7781 while ((child = bar_content. get_first_child ()) != null ) {
@@ -94,6 +98,18 @@ namespace Dc {
9498 sender = m. is_outgoing ? " You" : (m. sender_name ?? " " );
9599 }
96100
101+ /* Fetch from RPC if not in the loaded batch */
102+ if (text == null && sender == null && rpc != null ) {
103+ try {
104+ var msg_obj = yield rpc. get_message (rpc. account_id, pin_id);
105+ if (msg_obj != null ) {
106+ var fetched = RpcClient . parse_message (msg_obj, self_email);
107+ text = fetched. text;
108+ sender = fetched. is_outgoing ? " You" : (fetched. sender_name ?? " " );
109+ }
110+ } catch (Error e) { /* skip on error */ }
111+ }
112+
97113 if (text == null && sender == null ) continue ;
98114
99115 var row_btn = new Gtk .Button ();
0 commit comments