diff --git a/CHANGELOG.md b/CHANGELOG.md index df7e65039..6bdd844e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes +- avoid archived, fresh chats #3053 + + ## 1.75.0 ### Changes diff --git a/src/chat.rs b/src/chat.rs index c22e63f8b..50fc41035 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -474,22 +474,21 @@ impl ChatId { self ); - if visibility == ChatVisibility::Archived { - context - .sql - .execute( - "UPDATE msgs SET state=? WHERE chat_id=? AND state=?;", - paramsv![MessageState::InNoticed, self, MessageState::InFresh], - ) - .await?; - } - context .sql - .execute( - "UPDATE chats SET archived=? WHERE id=?;", - paramsv![visibility, self], - ) + .transaction(move |transaction| { + if visibility == ChatVisibility::Archived { + transaction.execute( + "UPDATE msgs SET state=? WHERE chat_id=? AND state=?;", + paramsv![MessageState::InNoticed, self, MessageState::InFresh], + )?; + } + transaction.execute( + "UPDATE chats SET archived=? WHERE id=?;", + paramsv![visibility, self], + )?; + Ok(()) + }) .await?; context.emit_event(EventType::MsgsChanged {