Fix queries being broken

This commit is contained in:
Sijmen 2023-11-29 02:05:44 +01:00
parent f15b092c26
commit 793422c7da
Signed by: vijfhoek
GPG key ID: DAF7821E067D9C48
2 changed files with 17 additions and 8 deletions

View file

@ -7,7 +7,9 @@ use iced::{
widget::{column, container, mouse_area, row, text, text_input},
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 tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
@ -190,7 +192,6 @@ impl Application for Cri {
fn update(&mut self, message: Self::Message) -> iced::Command<Self::Message> {
match message {
ui_message::UiMessage::IrcMessageReceived(message) => {
// TODO use actual nickname
let source_nickname: String =
message.source_nickname().unwrap_or(&self.nickname).into();
@ -252,11 +253,19 @@ impl Application for Cri {
IrcCommand::PRIVMSG(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.nickname,
&channel,
&source_nickname,
target_name,
source_nickname.unwrap(),
content,
message_id,
&timestamp,

View file

@ -287,14 +287,14 @@ impl<'a> MessageLog {
pub fn on_privmsg(
&mut self,
current_nickname: &str,
channel_name: &str,
target_name: &str,
nickname: &str,
message: &str,
message_id: Option<&str>,
timestamp: &DateTime<Local>,
) {
let is_active = self.active_channel.as_deref() == Some(channel_name);
let channel = self.get_mut(Some(channel_name));
let is_active = self.active_channel.as_deref() == Some(target_name);
let channel = self.get_mut(Some(target_name));
if channel.is_multiline {
Self::handle_multiline_message(channel, nickname, message, message_id);