Remove pseudo message after server replied

This commit is contained in:
Joscha 2022-08-02 21:43:30 +02:00
parent a0b89b3990
commit cfcc663169
5 changed files with 84 additions and 12 deletions

View file

@ -258,6 +258,20 @@ impl<M: Msg, S: MsgStore<M>> InnerTreeViewState<M, S> {
}
}
}
fn sent(&mut self, id: Option<M::Id>) {
if let Cursor::Pseudo { coming_from, .. } = &self.cursor {
if let Some(id) = id {
self.cursor = Cursor::Msg(id);
self.editor.clear();
} else {
self.cursor = match coming_from {
Some(id) => Cursor::Msg(id.clone()),
None => Cursor::Bottom,
};
};
}
}
}
pub struct TreeViewState<M: Msg, S: MsgStore<M>>(Arc<Mutex<InnerTreeViewState<M, S>>>);
@ -287,6 +301,10 @@ impl<M: Msg, S: MsgStore<M>> TreeViewState<M, S> {
.handle_key_event(terminal, crossterm_lock, event, can_compose)
.await
}
pub async fn sent(&mut self, id: Option<M::Id>) {
self.0.lock().await.sent(id)
}
}
////////////