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