diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 55c98da763..6de0e7ca72 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1010,11 +1010,11 @@ UPDATE config SET value=? WHERE keyname='configured_addr' AND value!=?1 && msg.chat_visibility == ChatVisibility::Archived; updated_chats .entry(msg.chat_id) - .and_modify(|ts| *ts = cmp::max(*ts, msg.timestamp_sort)) - .or_insert(msg.timestamp_sort); + .and_modify(|pos| *pos = cmp::max(*pos, (msg.timestamp_sort, msg.id))) + .or_insert((msg.timestamp_sort, msg.id)); } } - for (chat_id, timestamp_sort) in updated_chats { + for (chat_id, (timestamp_sort, msg_id)) in updated_chats { context .sql .execute( @@ -1023,12 +1023,13 @@ UPDATE msgs SET state=? WHERE state=? AND hidden=0 AND chat_id=? AND - timestamp