From 3f18b76c7deea08100642c200e9c316c35ee48f4 Mon Sep 17 00:00:00 2001 From: Joscha Date: Mon, 17 Apr 2023 10:25:07 +0200 Subject: [PATCH] Fix chat scrolling up after sending message --- src/ui/chat.rs | 1 + src/ui/chat/tree.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/ui/chat.rs b/src/ui/chat.rs index 24b0185..9e243e2 100644 --- a/src/ui/chat.rs +++ b/src/ui/chat.rs @@ -124,6 +124,7 @@ impl> ChatState { /// 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(); } diff --git a/src/ui/chat/tree.rs b/src/ui/chat/tree.rs index 6b09fa2..246e3c9 100644 --- a/src/ui/chat/tree.rs +++ b/src/ui/chat/tree.rs @@ -405,6 +405,12 @@ impl> TreeViewState { }) } + 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,