Rename second euph Message to SmallMessage
This commit is contained in:
parent
8e2e7d4764
commit
ac2602c4b8
5 changed files with 16 additions and 17 deletions
|
|
@ -1,10 +1,10 @@
|
|||
pub mod api;
|
||||
mod conn;
|
||||
mod message;
|
||||
mod room;
|
||||
mod small_message;
|
||||
mod util;
|
||||
|
||||
pub use conn::{Joined, Joining, Status};
|
||||
pub use message::Message;
|
||||
pub use room::Room;
|
||||
pub use small_message::SmallMessage;
|
||||
pub use util::{hue, nick_color, nick_style};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use super::api::{Snowflake, Time};
|
|||
use super::util;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Message {
|
||||
pub struct SmallMessage {
|
||||
pub id: Snowflake,
|
||||
pub parent: Option<Snowflake>,
|
||||
pub time: Time,
|
||||
|
|
@ -45,7 +45,7 @@ fn styled_content_me(content: &str) -> Styled {
|
|||
Styled::new(content.trim(), style).then("*", style)
|
||||
}
|
||||
|
||||
impl Msg for Message {
|
||||
impl Msg for SmallMessage {
|
||||
type Id = Snowflake;
|
||||
|
||||
fn id(&self) -> Self::Id {
|
||||
|
|
@ -61,7 +61,7 @@ impl Msg for Message {
|
|||
}
|
||||
}
|
||||
|
||||
impl ChatMsg for Message {
|
||||
impl ChatMsg for SmallMessage {
|
||||
fn time(&self) -> OffsetDateTime {
|
||||
self.time.0
|
||||
}
|
||||
|
|
@ -8,8 +8,8 @@ use time::format_description::FormatItem;
|
|||
use time::macros::format_description;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use crate::euph;
|
||||
use crate::euph::api::Snowflake;
|
||||
use crate::euph::SmallMessage;
|
||||
use crate::store::{MsgStore, Tree};
|
||||
use crate::vault::Vault;
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ pub async fn export(vault: &Vault, room: String, file: &Path) -> anyhow::Result<
|
|||
|
||||
fn write_tree(
|
||||
file: &mut BufWriter<File>,
|
||||
tree: &Tree<euph::Message>,
|
||||
tree: &Tree<SmallMessage>,
|
||||
id: Snowflake,
|
||||
indent: usize,
|
||||
) -> anyhow::Result<()> {
|
||||
|
|
@ -68,7 +68,7 @@ fn write_tree(
|
|||
fn write_msg(
|
||||
file: &mut BufWriter<File>,
|
||||
indent_string: &str,
|
||||
msg: &euph::Message,
|
||||
msg: &SmallMessage,
|
||||
) -> anyhow::Result<()> {
|
||||
let nick = &msg.nick;
|
||||
let nick_empty = " ".repeat(nick.width());
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ pub struct EuphRoom {
|
|||
state: State,
|
||||
|
||||
room: Option<euph::Room>,
|
||||
chat: ChatState<euph::Message, EuphVault>,
|
||||
chat: ChatState<euph::SmallMessage, EuphVault>,
|
||||
nick_list: ListState<String>,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,9 @@ use rusqlite::{named_params, params, Connection, OptionalExtension, ToSql, Trans
|
|||
use time::OffsetDateTime;
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
use crate::euph;
|
||||
use crate::euph::api::{Message, Snowflake, Time};
|
||||
use crate::store::{Msg, MsgStore, Path, Tree};
|
||||
use crate::ui::ChatMsg;
|
||||
use crate::euph::SmallMessage;
|
||||
use crate::store::{MsgStore, Path, Tree};
|
||||
|
||||
use super::{Request, Vault};
|
||||
|
||||
|
|
@ -131,7 +130,7 @@ impl EuphVault {
|
|||
}
|
||||
|
||||
#[async_trait]
|
||||
impl MsgStore<euph::Message> for EuphVault {
|
||||
impl MsgStore<SmallMessage> for EuphVault {
|
||||
async fn path(&self, id: &Snowflake) -> Path<Snowflake> {
|
||||
// TODO vault::Error
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
|
@ -144,7 +143,7 @@ impl MsgStore<euph::Message> for EuphVault {
|
|||
rx.await.unwrap()
|
||||
}
|
||||
|
||||
async fn tree(&self, tree_id: &Snowflake) -> Tree<euph::Message> {
|
||||
async fn tree(&self, tree_id: &Snowflake) -> Tree<SmallMessage> {
|
||||
// TODO vault::Error
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let request = EuphRequest::GetTree {
|
||||
|
|
@ -253,7 +252,7 @@ pub(super) enum EuphRequest {
|
|||
GetTree {
|
||||
room: String,
|
||||
root: Snowflake,
|
||||
result: oneshot::Sender<Tree<euph::Message>>,
|
||||
result: oneshot::Sender<Tree<SmallMessage>>,
|
||||
},
|
||||
GetPrevTreeId {
|
||||
room: String,
|
||||
|
|
@ -644,7 +643,7 @@ impl EuphRequest {
|
|||
conn: &Connection,
|
||||
room: String,
|
||||
root: Snowflake,
|
||||
result: oneshot::Sender<Tree<euph::Message>>,
|
||||
result: oneshot::Sender<Tree<SmallMessage>>,
|
||||
) -> rusqlite::Result<()> {
|
||||
let msgs = conn
|
||||
.prepare(
|
||||
|
|
@ -666,7 +665,7 @@ impl EuphRequest {
|
|||
",
|
||||
)?
|
||||
.query_map(params![room, root], |row| {
|
||||
Ok(euph::Message {
|
||||
Ok(SmallMessage {
|
||||
id: row.get(0)?,
|
||||
parent: row.get(1)?,
|
||||
time: row.get(2)?,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue