BlueGit

ict rusty-teams

fix(chats): honor the chat service hidden time

- a chat hidden via Graph reports hidden=false but a hidden time; it now stays hidden until a newer message
- test for the hidden time

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-09 · 3 weeks ago

Hash
96ae09c355fd08522e80eb2192bf1bd2a0a48f0f
Parent
a666fcc5
1 file changed +21 −1
crates/core/src/hidden_chats.rs +21 −1
@@ -115,7 +115,8 @@ pub(crate) fn resolve_hidden(
115 115 let cleared_until_ms = states
116 116 .get(&chat.id)
117 117 .and_then(|state| state.history_cleared_ms);
118 if history_cleared(chat, cleared_until_ms) {
118 let hidden_at_ms = states.get(&chat.id).and_then(|state| state.hidden_at_ms);
119 if history_cleared(chat, cleared_until_ms) || history_cleared(chat, hidden_at_ms) {
119 120 return true;
120 121 }
121 122 if reported == Some(true) {
@@ -235,6 +236,25 @@ mod tests {
235 236 ));
236 237 }
237 238
239 #[test]
240 fn a_hidden_time_hides_the_chat_although_chatsvc_says_visible() {
241 let mut locally = LocallyHidden::default();
242 let mut hidden = states(Some(false));
243 hidden.get_mut("19:a").unwrap().hidden_at_ms = Some(at("2026-10-01T10:00:00Z").timestamp_millis());
244 assert!(resolve_hidden(
245 &chat(Some("2026-10-01T09:00:00Z"), true),
246 &hidden,
247 &mut locally,
248 now()
249 ));
250 assert!(!resolve_hidden(
251 &chat(Some("2026-10-02T08:00:00Z"), true),
252 &hidden,
253 &mut locally,
254 now()
255 ));
256 }
257
238 258 fn hidden_after(text: &str) -> LocallyHidden {
239 259 let mut locally = LocallyHidden::default();
240 260 locally.hide("19:a", at(text));
@@ -115,7 +115,8 @@ pub(crate) fn resolve_hidden(
115 let cleared_until_ms = states
115 let cleared_until_ms = states
116 .get(&chat.id)
116 .get(&chat.id)
117 .and_then(|state| state.history_cleared_ms);
117 .and_then(|state| state.history_cleared_ms);
118 if history_cleared(chat, cleared_until_ms) {
118 let hidden_at_ms = states.get(&chat.id).and_then(|state| state.hidden_at_ms);
119 if history_cleared(chat, cleared_until_ms) || history_cleared(chat, hidden_at_ms) {
119 return true;
120 return true;
120 }
121 }
121 if reported == Some(true) {
122 if reported == Some(true) {
@@ -235,6 +236,25 @@ mod tests {
235 ));
236 ));
236 }
237 }
237
238
239 #[test]
240 fn a_hidden_time_hides_the_chat_although_chatsvc_says_visible() {
241 let mut locally = LocallyHidden::default();
242 let mut hidden = states(Some(false));
243 hidden.get_mut("19:a").unwrap().hidden_at_ms = Some(at("2026-10-01T10:00:00Z").timestamp_millis());
244 assert!(resolve_hidden(
245 &chat(Some("2026-10-01T09:00:00Z"), true),
246 &hidden,
247 &mut locally,
248 now()
249 ));
250 assert!(!resolve_hidden(
251 &chat(Some("2026-10-02T08:00:00Z"), true),
252 &hidden,
253 &mut locally,
254 now()
255 ));
256 }
257
238 fn hidden_after(text: &str) -> LocallyHidden {
258 fn hidden_after(text: &str) -> LocallyHidden {
239 let mut locally = LocallyHidden::default();
259 let mut locally = LocallyHidden::default();
240 locally.hide("19:a", at(text));
260 locally.hide("19:a", at(text));