Skip to content

Commit 894e419

Browse files
committed
changed: log msg formatting
1 parent 4f054ca commit 894e419

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ui/tab.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn render_tab_log(f: &mut Frame, app: &App) {
5555

5656
let mut text = Vec::new();
5757

58-
for (i, status) in conn.log().iter().enumerate() {
58+
for status in conn.log() {
5959
let desc = match (status.code(), &conn.conn_type) {
6060
(Ok(code), ConnectionType::Remote { .. }) => code.to_string(),
6161
(Ok(ms), ConnectionType::Local { .. }) => format!("{ms} ms"),
@@ -64,15 +64,16 @@ pub fn render_tab_log(f: &mut Frame, app: &App) {
6464

6565
let color = status_to_color(status, &conn.conn_type);
6666

67+
let time = status.timestamp();
68+
let now = chrono::Local::now();
69+
6770
// Identify the latest status.
68-
let left = if i == 0 {
69-
Span::styled(" Now ", Style::new().bg(color).fg(Color::Black).bold())
71+
let left = if now.signed_duration_since(time).num_milliseconds() < 75 {
72+
Span::styled("░░░░░░░", Style::new().bg(color).fg(Color::Black).bold())
7073
} else {
7174
Span::styled(" ", Style::new().bg(color))
7275
};
7376

74-
let time = status.timestamp().time();
75-
7677
text.push(Line::from(vec![
7778
left,
7879
Span::raw(" "),
@@ -98,7 +99,7 @@ pub fn render_tab_log(f: &mut Frame, app: &App) {
9899
f.render_widget(info, Rect::new(2, 1, f.area().width, f.area().height - 1));
99100
}
100101

101-
fn status_to_color(status: &app::Status, conn_type: &ConnectionType) -> Color {
102+
const fn status_to_color(status: &app::Status, conn_type: &ConnectionType) -> Color {
102103
let Ok(code) = status.code() else {
103104
return Color::Red;
104105
};

0 commit comments

Comments
 (0)