Compare commits

..

2 commits

Author SHA1 Message Date
8f1a3fdb29
Fix own message text color 2023-11-29 02:06:06 +01:00
793422c7da
Fix queries being broken 2023-11-29 02:05:44 +01:00
2 changed files with 18 additions and 10 deletions

View file

@ -7,7 +7,9 @@ use iced::{
widget::{column, container, mouse_area, row, text, text_input}, widget::{column, container, mouse_area, row, text, text_input},
Application, Background, Element, Length, Theme, Application, Background, Element, Length, Theme,
}; };
use irc::proto::{message::Tag, CapSubCommand, Capability, Command as IrcCommand, Response}; use irc::proto::{
message::Tag, CapSubCommand, Capability, ChannelExt, Command as IrcCommand, Response,
};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
@ -190,7 +192,6 @@ impl Application for Cri {
fn update(&mut self, message: Self::Message) -> iced::Command<Self::Message> { fn update(&mut self, message: Self::Message) -> iced::Command<Self::Message> {
match message { match message {
ui_message::UiMessage::IrcMessageReceived(message) => { ui_message::UiMessage::IrcMessageReceived(message) => {
// TODO use actual nickname
let source_nickname: String = let source_nickname: String =
message.source_nickname().unwrap_or(&self.nickname).into(); message.source_nickname().unwrap_or(&self.nickname).into();
@ -252,11 +253,19 @@ impl Application for Cri {
IrcCommand::PRIVMSG(msgtarget, content) IrcCommand::PRIVMSG(msgtarget, content)
| IrcCommand::NOTICE(msgtarget, content) => { | IrcCommand::NOTICE(msgtarget, content) => {
let channel: String = message.response_target().unwrap_or(msgtarget).into(); let source_nickname = message.source_nickname();
let target_name = if msgtarget.is_channel_name()
|| source_nickname == Some(&self.nickname)
{
msgtarget
} else {
source_nickname.unwrap_or(msgtarget)
};
self.message_log.on_privmsg( self.message_log.on_privmsg(
&self.nickname, &self.nickname,
&channel, target_name,
&source_nickname, source_nickname.unwrap(),
content, content,
message_id, message_id,
&timestamp, &timestamp,

View file

@ -287,14 +287,14 @@ impl<'a> MessageLog {
pub fn on_privmsg( pub fn on_privmsg(
&mut self, &mut self,
current_nickname: &str, current_nickname: &str,
channel_name: &str, target_name: &str,
nickname: &str, nickname: &str,
message: &str, message: &str,
message_id: Option<&str>, message_id: Option<&str>,
timestamp: &DateTime<Local>, timestamp: &DateTime<Local>,
) { ) {
let is_active = self.active_channel.as_deref() == Some(channel_name); let is_active = self.active_channel.as_deref() == Some(target_name);
let channel = self.get_mut(Some(channel_name)); let channel = self.get_mut(Some(target_name));
if channel.is_multiline { if channel.is_multiline {
Self::handle_multiline_message(channel, nickname, message, message_id); Self::handle_multiline_message(channel, nickname, message, message_id);
@ -449,11 +449,10 @@ impl<'a> MessageLog {
} }
MessageDetail::Privmsg { nickname, message } => { MessageDetail::Privmsg { nickname, message } => {
let is_self = nickname == current_nickname; let is_self = nickname == current_nickname;
let text_color = if is_self { util::DARK_RED } else { util::BLACK };
let message_appearance = Self::container_appearance(util::WHITE, 8.0); let message_appearance = Self::container_appearance(util::WHITE, 8.0);
let own_message_appearance = Self::container_appearance(util::LIGHTER_GREEN, 8.0); let own_message_appearance = Self::container_appearance(util::LIGHTER_GREEN, 8.0);
let mut elements: Vec<Element<'_, _, _>> = let mut elements: Vec<Element<'_, _, _>> =
vec![text(message).style(text_color).into()]; vec![text(message).style(util::BLACK).into()];
if !is_self { if !is_self {
elements.insert(0, text(nickname).style(util::DARK_RED).into()); elements.insert(0, text(nickname).style(util::DARK_RED).into());