Преглед изворни кода

wallet: chatview avoid redrawing() when bgloader loads messages that aren't visible onscreen.

darkfi пре 1 година
родитељ
комит
355d8a6a65
1 измењених фајлова са 5 додато и 3 уклоњено
  1. 5 3
      bin/darkwallet/src/ui/chatview/mod.rs

+ 5 - 3
bin/darkwallet/src/ui/chatview/mod.rs

@@ -634,6 +634,7 @@ impl ChatView {
         // Keep loading until this is below 0
         let mut remaining_load_height = top + preload_height - total_height;
         debug!(target: "ui::chatview", "bgloader: remaining px = {remaining_load_height}");
+        let mut remaining_visible = top - total_height;
 
         // Get the current earliest timestamp
         let iter = match msgbuf.oldest_timestamp() {
@@ -670,9 +671,10 @@ impl ChatView {
                 break
             }
 
-            // todo: if msg is visible {
-            self.redraw_cached(&mut msgbuf).await;
-            // }
+            if remaining_visible > 0. {
+                self.redraw_cached(&mut msgbuf).await;
+            }
+            remaining_visible -= msg_height;
         }
     }