Switch to Columns
Also refactor damus app usage to only pass in things that we need in views. Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
22
src/draft.rs
22
src/draft.rs
@@ -7,16 +7,21 @@ pub struct Draft {
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Drafts {
|
||||
pub replies: HashMap<[u8; 32], Draft>,
|
||||
pub compose: Draft,
|
||||
replies: HashMap<[u8; 32], Draft>,
|
||||
compose: Draft,
|
||||
}
|
||||
|
||||
impl Drafts {
|
||||
pub fn clear(&mut self, source: DraftSource) {
|
||||
source.draft(self).buffer = "".to_string();
|
||||
pub fn compose_mut(&mut self) -> &mut Draft {
|
||||
&mut self.compose
|
||||
}
|
||||
|
||||
pub fn reply_mut(&mut self, id: &[u8; 32]) -> &mut Draft {
|
||||
self.replies.entry(*id).or_default()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
pub enum DraftSource<'a> {
|
||||
Compose,
|
||||
Reply(&'a [u8; 32]), // note id
|
||||
@@ -25,14 +30,19 @@ pub enum DraftSource<'a> {
|
||||
impl<'a> DraftSource<'a> {
|
||||
pub fn draft(&self, drafts: &'a mut Drafts) -> &'a mut Draft {
|
||||
match self {
|
||||
DraftSource::Compose => &mut drafts.compose,
|
||||
DraftSource::Reply(id) => drafts.replies.entry(**id).or_default(),
|
||||
DraftSource::Compose => drafts.compose_mut(),
|
||||
DraftSource::Reply(id) => drafts.reply_mut(id),
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
impl Draft {
|
||||
pub fn new() -> Self {
|
||||
Draft::default()
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.buffer = "".to_string();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user