From b04127d0c23152ea76fcff69200cbbd894bacbf6 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Thu, 22 Aug 2019 22:07:36 -0700 Subject: [PATCH] fractal-gtk: room_history: Allow removing a message Signed-off-by: Alistair Francis --- fractal-gtk/src/widgets/room_history.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fractal-gtk/src/widgets/room_history.rs b/fractal-gtk/src/widgets/room_history.rs index ea8407ad..4a6beb4f 100644 --- a/fractal-gtk/src/widgets/room_history.rs +++ b/fractal-gtk/src/widgets/room_history.rs @@ -267,6 +267,20 @@ impl RoomHistory { None } + pub fn remove_message(&mut self, item: MessageContent) -> Option<()> { + let mut rows = self.rows.borrow_mut(); + let ref mut msg = rows.list.iter_mut().find_map(|e| match e { + Element::Message(ref mut itermessage) if itermessage.id == item.id => Some(itermessage), + _ => None, + })?; + + 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) -> Option<()> { /* TODO: use lazy loading */ for item in messages {