Show unknown messages in Server log

This commit is contained in:
Sijmen 2023-11-16 19:46:24 +01:00
parent 4a10e38cfc
commit 6ca03dcfc8
Signed by: vijfhoek
GPG key ID: DAF7821E067D9C48
3 changed files with 11 additions and 1 deletions

View file

@ -18,4 +18,7 @@ pub enum IrcMessage {
nickname: String, nickname: String,
message: String, message: String,
}, },
Other {
message: String,
},
} }

View file

@ -160,7 +160,7 @@ impl Application for Cri {
.on_privmsg(channel, &source_nickname, content); .on_privmsg(channel, &source_nickname, content);
} }
_ => (), _ => self.message_log.on_other(&message.to_string()),
} }
} }
UiMessage::InputChanged(text) => self.input_value = text, UiMessage::InputChanged(text) => self.input_value = text,

View file

@ -68,6 +68,12 @@ impl<'a> MessageLog {
}) })
} }
pub(crate) fn on_other(&mut self, message: &str) {
self.get_mut(None).push(IrcMessage::Other {
message: message.trim().to_string(),
})
}
pub fn view(&self, active_channel: &Option<String>) -> Container<'_, crate::UiMessage> { pub fn view(&self, active_channel: &Option<String>) -> Container<'_, crate::UiMessage> {
let lighter_grey = Color::new(0.93, 0.94, 0.95, 1.0); let lighter_grey = Color::new(0.93, 0.94, 0.95, 1.0);
let dark_grey = Color::new(0.58, 0.65, 0.65, 1.0); let dark_grey = Color::new(0.58, 0.65, 0.65, 1.0);
@ -188,6 +194,7 @@ impl<'a> MessageLog {
.into(), .into(),
) )
} }
IrcMessage::Other { message } => Some(text(message).into()),
} }
}) })
.map(|element| element.into()) .map(|element| element.into())