From 7e242fde2618e010a5b1c0245adbfa0d93c467f2 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 21 Aug 2024 16:59:18 +0200 Subject: [PATCH] Fix panic in apply_difference_type Closes #258. --- lib/grammers-session/src/message_box/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/grammers-session/src/message_box/mod.rs b/lib/grammers-session/src/message_box/mod.rs index 24ec5157..26a90967 100644 --- a/lib/grammers-session/src/message_box/mod.rs +++ b/lib/grammers-session/src/message_box/mod.rs @@ -739,7 +739,14 @@ impl MessageBox { chat_hashes: &mut ChatHashCache, ) -> defs::UpdateAndPeers { self.map.get_mut(&Entry::AccountWide).unwrap().pts = state.pts; - self.map.get_mut(&Entry::SecretChats).unwrap().pts = state.qts; + self.map + .entry(Entry::SecretChats) + // AccountWide affects SecretChats, but this may not have been initialized yet (#258) + .or_insert_with(|| State { + pts: NO_PTS, + deadline: next_updates_deadline(), + }) + .pts = state.qts; self.date = state.date; self.seq = state.seq;