Skip to content

Commit 60d722f

Browse files
committed
Replace nested scroll timeout with adjustment notify guard
1 parent 458bcb4 commit 60d722f

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/window.vala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,16 +562,18 @@ namespace Dc {
562562
}
563563
message_store.splice (0, message_store.get_n_items (), batch);
564564

565-
Idle.add (() => {
566-
scroll_to_bottom ();
567-
Timeout.add (50, () => {
565+
if (messages.length == 0) {
566+
loading_chat = false;
567+
scroll_down_btn.visible = !is_near_bottom ();
568+
} else {
569+
ulong scroll_handler_id = 0;
570+
scroll_handler_id = message_scroll.vadjustment.notify["upper"].connect (() => {
568571
scroll_to_bottom ();
569572
loading_chat = false;
570573
scroll_down_btn.visible = !is_near_bottom ();
571-
return Source.REMOVE;
574+
SignalHandler.disconnect (message_scroll.vadjustment, scroll_handler_id);
572575
});
573-
return Source.REMOVE;
574-
});
576+
}
575577

576578
pinned.update_bar.begin ();
577579
} catch (Error e) {

0 commit comments

Comments
 (0)