Move struct Channel to separate module
This commit is contained in:
parent
ce5b4fb2ac
commit
a3f775222f
3 changed files with 49 additions and 43 deletions
46
src/channel.rs
Normal file
46
src/channel.rs
Normal 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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
mod channel;
|
||||||
mod cri;
|
mod cri;
|
||||||
mod cri_flags;
|
mod cri_flags;
|
||||||
mod irc_handler;
|
mod irc_handler;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
|
channel::Channel,
|
||||||
irc_message::{IrcMessage, MessageDetail},
|
irc_message::{IrcMessage, MessageDetail},
|
||||||
util::{self, BATCH_SUB_COMMAND_CHATHISTORY},
|
util::{self, BATCH_SUB_COMMAND_CHATHISTORY},
|
||||||
};
|
};
|
||||||
|
@ -10,49 +11,7 @@ use iced::{
|
||||||
Background, Color, Element, Length,
|
Background, Color, Element, Length,
|
||||||
};
|
};
|
||||||
use irc::proto::BatchSubCommand;
|
use irc::proto::BatchSubCommand;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::HashMap;
|
||||||
|
|
||||||
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,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct MessageLog {
|
pub struct MessageLog {
|
||||||
channels: HashMap<Option<String>, Channel>,
|
channels: HashMap<Option<String>, Channel>,
|
||||||
|
|
Loading…
Reference in a new issue