From 237dabb90758747c5a781b945bd018280bf700f3 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 28 Mar 2020 22:09:06 +0300 Subject: [PATCH] Do not hide hidden messages in ChatId.delete_device_expired_messages() This prevents infinite event loop, when chatlist is reloaded in response to event, and event is emitted by hiding messages before chatlist reload. --- src/chat.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/chat.rs b/src/chat.rs index eb022d3d5..11f365a05 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -389,11 +389,15 @@ impl ChatId { let threshold_timestamp = time() - delete_device_after; // Hide expired messages + // + // Only update the rows that have to be updated, to avoid emitting + // unnecessary "chat modified" events. let rows_modified = context.sql.execute( "UPDATE msgs \ SET txt = 'DELETED', hidden = 1 \ WHERE timestamp < ? \ - AND chat_id == ?", + AND chat_id == ? \ + AND NOT hidden", params![threshold_timestamp, self], )?;