Fix queries being broken
This commit is contained in:
parent
f15b092c26
commit
793422c7da
2 changed files with 17 additions and 8 deletions
19
src/cri.rs
19
src/cri.rs
|
@ -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,
|
||||||
×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,
|
||||||
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);
|
||||||
|
|
Loading…
Reference in a new issue