From e4265e690e53fc571b032007cb8b1a6c9b3e6f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Moreno?= Date: Wed, 30 Aug 2017 18:06:55 +0200 Subject: [PATCH] Don't scroll when other room message is received --- src/app.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/app.rs b/src/app.rs index e41d2766..6aa245b9 100644 --- a/src/app.rs +++ b/src/app.rs @@ -499,10 +499,9 @@ impl AppOp { } } - pub fn mark_as_read(&self, msgs: Vec) { - if let Some(msg) = msgs.iter().filter(|x| x.room == self.active_room).last() { - self.backend.send(BKCommand::MarkAsRead(msg.room.clone(), msg.id.clone())).unwrap(); - } + pub fn mark_as_read(&self, msg: &Message) { + self.backend.send(BKCommand::MarkAsRead(msg.room.clone(), + msg.id.clone())).unwrap(); } pub fn add_room_member(&mut self, m: Member) { @@ -662,8 +661,11 @@ impl AppOp { } if !msgs.is_empty() { - self.scroll_down(); - self.mark_as_read(msgs); + let fs = msgs.iter().filter(|x| x.room == self.active_room); + if let Some(msg) = fs.last() { + self.scroll_down(); + self.mark_as_read(msg); + } } if init {