From 5f285c854ab3b942c0a49ee637696d2df20eb2c9 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Wed, 6 Nov 2024 21:46:39 +0000 Subject: [PATCH] Fix migrating to stable memory for chats with disappearing messages (#6746) --- backend/canisters/community/CHANGELOG.md | 4 ++++ backend/canisters/group/CHANGELOG.md | 4 ++++ backend/libraries/chat_events/src/chat_events_list.rs | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/canisters/community/CHANGELOG.md b/backend/canisters/community/CHANGELOG.md index 0b133a9d9c..d64cbfe994 100644 --- a/backend/canisters/community/CHANGELOG.md +++ b/backend/canisters/community/CHANGELOG.md @@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Consolidate `summary` and `c2c_summary` args ([#6723](https://github.com/open-chat-labs/open-chat/pull/6723)) - Fix case where some thread messages were not updated in stable memory ([#6736](https://github.com/open-chat-labs/open-chat/pull/6736)) +### Fixed + +- Fix migrating to stable memory for chats with disappearing messages ([#6746](https://github.com/open-chat-labs/open-chat/pull/6746)) + ## [[2.0.1423](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1423-community)] - 2024-11-05 ### Changed diff --git a/backend/canisters/group/CHANGELOG.md b/backend/canisters/group/CHANGELOG.md index 73cb773ca6..a505f58025 100644 --- a/backend/canisters/group/CHANGELOG.md +++ b/backend/canisters/group/CHANGELOG.md @@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Consolidate `summary` and `c2c_summary` args ([#6723](https://github.com/open-chat-labs/open-chat/pull/6723)) - Fix case where some thread messages were not updated in stable memory ([#6736](https://github.com/open-chat-labs/open-chat/pull/6736)) +### Fixed + +- Fix migrating to stable memory for chats with disappearing messages ([#6746](https://github.com/open-chat-labs/open-chat/pull/6746)) + ## [[2.0.1424](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1424-group)] - 2024-11-05 ### Changed diff --git a/backend/libraries/chat_events/src/chat_events_list.rs b/backend/libraries/chat_events/src/chat_events_list.rs index 939798027f..2989f00852 100644 --- a/backend/libraries/chat_events/src/chat_events_list.rs +++ b/backend/libraries/chat_events/src/chat_events_list.rs @@ -49,7 +49,7 @@ impl ChatEventsList { next_event_index = event.index.incr(); self.stable_events_map.insert(event); } - if Some(next_event_index) > self.latest_event_index { + if count < max_events || Some(next_event_index) > self.latest_event_index { (count, None) } else { (count, Some(next_event_index))