[fractal/af/redact.next: 1/5] fractal-gtk: room_history: Allow removing a message



commit e56fc10982c05ea000d9f9f5f9b4452d6998919b
Author: Alistair Francis <alistair alistair23 me>
Date:   Thu Aug 22 22:07:36 2019 -0700

    fractal-gtk: room_history: Allow removing a message
    
    Signed-off-by: Alistair Francis <alistair alistair23 me>

 fractal-gtk/src/widgets/room_history.rs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/fractal-gtk/src/widgets/room_history.rs b/fractal-gtk/src/widgets/room_history.rs
index 36bc4382..af895f99 100644
--- a/fractal-gtk/src/widgets/room_history.rs
+++ b/fractal-gtk/src/widgets/room_history.rs
@@ -267,6 +267,26 @@ impl RoomHistory {
         None
     }
 
+    pub fn remove_message(&mut self, item: MessageContent) -> Option<()> {
+        let mut rows = self.rows.borrow_mut();
+
+        let ref mut message = rows.list.iter_mut().find(|e| match e {
+            Element::Message(ref itermessage) => itermessage.id == item.id,
+            _ => false,
+        })?;
+
+        match message {
+            Element::Message(ref mut msg) => {
+                let msg_widget = msg.widget.clone()?;
+                msg.msg.redacted = true;
+                rows.listbox.remove(msg_widget.get_listbox_row()?);
+            }
+            _ => {}
+        }
+
+        None
+    }
+
     pub fn add_new_messages_in_batch(&mut self, messages: Vec<MessageContent>) -> Option<()> {
         /* TODO: use lazy loading */
         for item in messages {


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