Просмотр исходного кода

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

darkfi 1 год назад
Родитель
Сommit
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
         // Keep loading until this is below 0
         let mut remaining_load_height = top + preload_height - total_height;
         let mut remaining_load_height = top + preload_height - total_height;
         debug!(target: "ui::chatview", "bgloader: remaining px = {remaining_load_height}");
         debug!(target: "ui::chatview", "bgloader: remaining px = {remaining_load_height}");
+        let mut remaining_visible = top - total_height;
 
 
         // Get the current earliest timestamp
         // Get the current earliest timestamp
         let iter = match msgbuf.oldest_timestamp() {
         let iter = match msgbuf.oldest_timestamp() {
@@ -670,9 +671,10 @@ impl ChatView {
                 break
                 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;
         }
         }
     }
     }