Fix chat scrolling up after sending message

This commit is contained in:
Joscha 2023-04-17 10:25:07 +02:00
parent 21bb87fd45
commit 3f18b76c7d
2 changed files with 7 additions and 0 deletions

View file

@ -124,6 +124,7 @@ impl<M: Msg, S: MsgStore<M>> ChatState<M, S> {
/// A [`Reaction::Composed`] message was sent successfully.
pub fn send_successful(&mut self, id: M::Id) {
if let Cursor::Pseudo { .. } = &self.cursor {
self.tree.send_successful(&id);
self.cursor = Cursor::Msg(id);
self.editor.clear();
}

View file

@ -405,6 +405,12 @@ impl<M: Msg, S: MsgStore<M>> TreeViewState<M, S> {
})
}
pub fn send_successful(&mut self, id: &M::Id) {
if let Cursor::Pseudo { .. } = self.last_cursor {
self.last_cursor = Cursor::Msg(id.clone());
}
}
pub fn widget<'a>(
&'a mut self,
cursor: &'a mut Cursor<M::Id>,