bug fix: only print Incoming/ Outgoing/ Manual once

move title outside for loop so it doesn't get printed recursively.
This commit is contained in:
lunar-mining
2022-03-18 18:21:40 +01:00
parent 7b57c39314
commit ce810207e9

View File

@@ -33,7 +33,13 @@ 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 slot in outbound.slots.clone() {
let addr = Span::styled(format!(" {}", slot.addr), style);
@@ -54,12 +60,13 @@ pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
}
}
}
//debug!("{:?}", &node.inbound);
// 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 {
//debug!("{:?}", inbound);
if inbound.is_empty == false {
lines.push(Spans::from(Span::styled(" Incoming", Style::default())));
data.push("Incoming".to_string());
let addr = Span::styled(format!(" {}", inbound.connected), style);
data.push(format!("{}", inbound.connected));
let msg: Span = match inbound.channel.last_status.as_str() {
@@ -77,9 +84,12 @@ pub fn ui<B: Backend>(f: &mut Frame<'_, B>, mut view: View) {
lines.push(Spans::from(vec![addr, msg]));
}
}
for connect in &node.manual {
// 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));
}
@@ -90,7 +100,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);
}