[fractal] Fix message replacement and removal in room_history



commit eebb5b5dc80469acb6228643e8c5a76375311766
Author: Kai A. Hiller <V02460 gmail com>
Date:   Wed Dec 2 16:09:13 2020 +0100

    Fix message replacement and removal in room_history

 fractal-gtk/src/widgets/room_history.rs | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/fractal-gtk/src/widgets/room_history.rs b/fractal-gtk/src/widgets/room_history.rs
index 9f83b3d0..f53f1770 100644
--- a/fractal-gtk/src/widgets/room_history.rs
+++ b/fractal-gtk/src/widgets/room_history.rs
@@ -81,8 +81,8 @@ impl List {
     /// ### Panics
     /// Panics if `index >= len`.
     fn remove_item(&mut self, index: usize) {
-        self.list.remove(index);
-        self.view.remove(self.list.len() - index - 1);
+        self.view.remove(index);
+        self.list.remove(self.list.len() - index - 1);
     }
 
     /// Replaces the element at the given position in the history.
@@ -90,10 +90,10 @@ impl List {
     /// ### Panics
     /// Panics if `index >= len`.
     fn replace_item(&mut self, index: usize, element: Element) {
-        self.view.remove(self.list.len() - index - 1);
-        self.view
-            .insert(self.list.len() - index - 1, element.get_listbox_row());
-        self.list[index] = element;
+        self.view.remove(index);
+        self.view.insert(index, element.get_listbox_row());
+        let i_rev = self.list.len() - index - 1;
+        self.list[i_rev] = element;
     }
 
     fn create_new_message_divider(rows: Rc<RefCell<Self>>) -> widgets::NewMessageDivider {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]