From e9d9766d72740c7d7c9918b4839f3379f57cd6ef Mon Sep 17 00:00:00 2001 From: lancebord Date: Tue, 10 Mar 2026 11:07:44 -0400 Subject: merge consecutive join/part messages --- src/tui/app.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/tui') diff --git a/src/tui/app.rs b/src/tui/app.rs index 52fc85a..47af74d 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -6,6 +6,7 @@ pub struct ChatLine { pub nick: String, pub text: String, pub is_system: bool, + pub is_join_leave: bool, pub is_notice: bool, } @@ -46,6 +47,7 @@ impl AppState { nick: nick.to_string(), text: text.to_string(), is_system: false, + is_join_leave: false, is_notice: false, }); } @@ -55,6 +57,24 @@ impl AppState { nick: String::new(), text: text.to_string(), is_system: true, + is_join_leave: false, + is_notice: false, + }); + } + + pub fn push_join_leave(&mut self, text: &str) { + if let Some(m) = self.messages.last_mut() { + if m.is_join_leave { + m.text += format!(" {text}").as_str(); + return; + } + } + + self.messages.push(ChatLine { + nick: String::new(), + text: text.to_string(), + is_system: true, + is_join_leave: true, is_notice: false, }); } -- cgit v1.2.3-59-g8ed1b