Compare commits

...

2 commits

Author SHA1 Message Date
03f0ea717a
Change 100.to_string() to "100".into() 2023-12-01 04:06:57 +01:00
a3f775222f
Move struct Channel to separate module 2023-12-01 04:06:39 +01:00
4 changed files with 50 additions and 49 deletions

46
src/channel.rs Normal file
View file

@ -0,0 +1,46 @@
use chrono::{DateTime, Local};
use std::collections::HashSet;
use crate::irc_message::IrcMessage;
pub struct Channel {
pub channel_name: Option<String>,
pub messages: Vec<IrcMessage>,
pub message_ids: HashSet<String>,
pub names: Vec<String>,
pub topic: Option<String>,
pub unread_messages: i32,
pub unread_highlights: i32,
pub unread_events: i32,
pub is_multiline: bool,
pub multiline_privmsgs: Option<Vec<String>>,
pub multiline_timestamp: Option<DateTime<Local>>,
pub multiline_nickname: Option<String>,
pub multiline_message_id: Option<String>,
}
impl Channel {
pub fn new(channel_name: Option<&str>) -> Self {
Self {
channel_name: channel_name.map(String::from),
messages: Vec::new(),
message_ids: HashSet::new(),
names: Vec::new(),
topic: None,
unread_messages: 0,
unread_highlights: 0,
unread_events: 0,
is_multiline: false,
multiline_privmsgs: None,
multiline_timestamp: None,
multiline_nickname: None,
multiline_message_id: None,
}
}
}

View file

@ -174,12 +174,7 @@ impl Cri {
.send(
IrcCommand::Raw(
"CHATHISTORY".into(),
vec![
"LATEST".into(),
chanlist.into(),
"*".into(),
100.to_string(),
],
vec!["LATEST".into(), chanlist.into(), "*".into(), "100".into()],
)
.into(),
)

View file

@ -1,3 +1,4 @@
mod channel;
mod cri;
mod cri_flags;
mod irc_handler;

View file

@ -1,4 +1,5 @@
use crate::{
channel::Channel,
irc_message::{IrcMessage, MessageDetail},
util::{self, BATCH_SUB_COMMAND_CHATHISTORY},
};
@ -10,49 +11,7 @@ use iced::{
Background, Color, Element, Length,
};
use irc::proto::BatchSubCommand;
use std::collections::{HashMap, HashSet};
pub struct Channel {
pub channel_name: Option<String>,
pub messages: Vec<IrcMessage>,
pub message_ids: HashSet<String>,
pub names: Vec<String>,
pub topic: Option<String>,
pub unread_messages: i32,
pub unread_highlights: i32,
pub unread_events: i32,
pub is_multiline: bool,
pub multiline_privmsgs: Option<Vec<String>>,
pub multiline_timestamp: Option<chrono::DateTime<Local>>,
pub multiline_nickname: Option<String>,
pub multiline_message_id: Option<String>,
}
impl Channel {
fn new(channel_name: Option<&str>) -> Self {
Self {
channel_name: channel_name.map(String::from),
messages: Vec::new(),
message_ids: HashSet::new(),
names: Vec::new(),
topic: None,
unread_messages: 0,
unread_highlights: 0,
unread_events: 0,
is_multiline: false,
multiline_privmsgs: None,
multiline_timestamp: None,
multiline_nickname: None,
multiline_message_id: None,
}
}
}
use std::collections::HashMap;
pub struct MessageLog {
channels: HashMap<Option<String>, Channel>,