Compare commits
No commits in common. "8f1a3fdb2951a103326f50320eb9aa201d88c128" and "f15b092c26e8d4c8209f1f7fbf8539c95a77d8c4" have entirely different histories.
8f1a3fdb29
...
f15b092c26
2 changed files with 10 additions and 18 deletions
19
src/cri.rs
19
src/cri.rs
|
@ -7,9 +7,7 @@ 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::{
|
use irc::proto::{message::Tag, CapSubCommand, Capability, Command as IrcCommand, Response};
|
||||||
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};
|
||||||
|
|
||||||
|
@ -192,6 +190,7 @@ 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();
|
||||||
|
|
||||||
|
@ -253,19 +252,11 @@ impl Application for Cri {
|
||||||
|
|
||||||
IrcCommand::PRIVMSG(msgtarget, content)
|
IrcCommand::PRIVMSG(msgtarget, content)
|
||||||
| IrcCommand::NOTICE(msgtarget, content) => {
|
| IrcCommand::NOTICE(msgtarget, content) => {
|
||||||
let source_nickname = message.source_nickname();
|
let channel: String = message.response_target().unwrap_or(msgtarget).into();
|
||||||
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,
|
||||||
target_name,
|
&channel,
|
||||||
source_nickname.unwrap(),
|
&source_nickname,
|
||||||
content,
|
content,
|
||||||
message_id,
|
message_id,
|
||||||
×tamp,
|
×tamp,
|
||||||
|
|
|
@ -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,
|
||||||
target_name: &str,
|
channel_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(target_name);
|
let is_active = self.active_channel.as_deref() == Some(channel_name);
|
||||||
let channel = self.get_mut(Some(target_name));
|
let channel = self.get_mut(Some(channel_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,10 +449,11 @@ 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(util::BLACK).into()];
|
vec![text(message).style(text_color).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());
|
||||||
|
|
Loading…
Reference in a new issue