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

bug fix: stop rendering outbound recursively

move outbound outside loop
lunar-mining 4 лет назад
Родитель
Сommit
6165a9fb96
2 измененных файлов с 30 добавлено и 33 удалено
  1. 3 3
      bin/dnetview/src/main.rs
  2. 27 30
      bin/dnetview/src/ui.rs

+ 3 - 3
bin/dnetview/src/main.rs

@@ -225,11 +225,11 @@ async fn poll(client: Map, model: Arc<Model>) -> Result<()> {
                     );
                     slots.push(new_slot)
                 }
-                let is_empty = is_empty_outbound(slots.clone());
-                let oinfo = OutboundInfo::new(is_empty, slots.clone());
-                oconnects.push(oinfo);
             }
 
+            let is_empty = is_empty_outbound(slots.clone());
+            let oinfo = OutboundInfo::new(is_empty, slots.clone());
+            oconnects.push(oinfo);
             let infos = NodeInfo { outbound: oconnects, manual: mconnects, inbound: iconnects };
             let mut node_info = HashMap::new();
 

+ 27 - 30
bin/dnetview/src/ui.rs

@@ -33,14 +33,10 @@ pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
             //
             //      2. Fix error whereby duplicates outbounds are being printed (nested loop)
             Some(node) => {
-                // create the title
                 if !node.outbound.is_empty() {
                     lines.push(Spans::from(Span::styled("   Outgoing", Style::default())));
                     data.push("Outgoing".to_string());
-                }
-                for outbound in &node.outbound.clone() {
-                    debug!("{:?}", outbound);
-                    if outbound.is_empty == false {
+                    for outbound in &node.outbound.clone() {
                         for slot in outbound.slots.clone() {
                             let addr = Span::styled(format!("       {}", slot.addr), style);
                             data.push(format!("{}", slot.addr));
@@ -60,38 +56,39 @@ pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
                         }
                     }
                 }
-                // create the title
                 if !node.inbound.is_empty() {
                     lines.push(Spans::from(Span::styled("   Incoming", Style::default())));
                     data.push("Incoming".to_string());
-                }
-                for inbound in &node.inbound {
-                    if inbound.is_empty == false {
-                        let addr = Span::styled(format!("       {}", inbound.connected), style);
-                        data.push(format!("{}", inbound.connected));
-                        let msg: Span = match inbound.channel.last_status.as_str() {
-                            "recv" => Span::styled(
-                                format!("               [R: {}]", inbound.channel.last_msg),
-                                style,
-                            ),
-                            "sent" => Span::styled(
-                                format!("               [R: {}]", inbound.channel.last_msg),
-                                style,
-                            ),
-                            a => Span::styled(a.to_string(), style),
-                        };
-                        data.push(format!("{}", inbound.channel.last_msg));
-                        lines.push(Spans::from(vec![addr, msg]));
+                    for inbound in &node.inbound {
+                        if inbound.is_empty == false {
+                            let addr = Span::styled(format!("       {}", inbound.connected), style);
+                            data.push(format!("{}", inbound.connected));
+                            let msg: Span = match inbound.channel.last_status.as_str() {
+                                "recv" => Span::styled(
+                                    format!("               [R: {}]", inbound.channel.last_msg),
+                                    style,
+                                ),
+                                "sent" => Span::styled(
+                                    format!("               [R: {}]", inbound.channel.last_msg),
+                                    style,
+                                ),
+                                a => Span::styled(a.to_string(), style),
+                            };
+                            data.push(format!("{}", inbound.channel.last_msg));
+                            lines.push(Spans::from(vec![addr, msg]));
+                        }
                     }
                 }
-                // create the title
                 if !node.manual.is_empty() {
                     lines.push(Spans::from(Span::styled("   Manual", Style::default())));
                     data.push("Manual".to_string());
-                }
-                for connect in &node.manual {
-                    lines.push(Spans::from(Span::styled(format!("       {}", connect.key), style)));
-                    data.push(format!("{}", connect.key));
+                    for connect in &node.manual {
+                        lines.push(Spans::from(Span::styled(
+                            format!("       {}", connect.key),
+                            style,
+                        )));
+                        data.push(format!("{}", connect.key));
+                    }
                 }
             }
             None => {
@@ -100,7 +97,7 @@ pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
             }
         }
 
-        debug!("{:?}", data);
+        //debug!("{:?}", data);
         let ids = ListItem::new(lines);
         nodes.push(ids);
     }