fix(chats): drop cached chats hidden by the chat service hidden time
- incremental syncs never re-check unchanged cached chats; the state refresh now removes them - a fresh local unhide still wins Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -141,18 +141,43 @@ impl<R: Remote> SyncEngine<R> {
141
141
.filter(|state| state.hidden == Some(true))
142
142
.map(|state| state.id.as_str())
143
143
.collect();
144
let hidden_by_time: Vec<&str> = states
145
.unwrap_or_default()
146
.iter()
147
.filter(|state| self.cached_chat_hidden_by_time(state))
148
.map(|state| state.id.as_str())
149
.collect();
144
150
let now = Utc::now();
145
151
let hidden: Vec<String> = self.with_locally_hidden(|locally| {
146
reported
152
let mut hidden: Vec<String> = reported
147
153
.iter()
148
154
.filter(|chat_id| locally.reported_hidden(chat_id, now))
149
155
.map(|chat_id| (*chat_id).to_owned())
150
.collect()
156
.collect();
157
hidden.extend(
158
hidden_by_time
159
.iter()
160
.filter(|chat_id| !locally.unhide_override_active(chat_id, now))
161
.map(|chat_id| (*chat_id).to_owned()),
162
);
163
hidden
151
164
})?;
152
165
self.store.remove_chats(&hidden)?;
153
166
Ok(())
154
167
}
155
168
169
fn cached_chat_hidden_by_time(&self, state: &ConversationState) -> bool {
170
let Some(hidden_at_ms) = state.hidden_at_ms else {
171
return false;
172
};
173
match self.store.chat(&state.id) {
174
Ok(Some(chat)) => chat
175
.last_message_at
176
.is_none_or(|last| last.timestamp_millis() <= hidden_at_ms),
177
_ => false,
178
}
179
}
180
156
181
async fn refresh_app_channel_horizon(&self) -> i64 {
157
182
match self.remote.app_consumption_horizon().await {
158
183
Ok(horizon) => {
@@ -141,18 +141,43 @@ impl<R: Remote> SyncEngine<R> {141
.filter(|state| state.hidden == Some(true))141
.filter(|state| state.hidden == Some(true))142
.map(|state| state.id.as_str())142
.map(|state| state.id.as_str())143
.collect();143
.collect();144
let hidden_by_time: Vec<&str> = states145
.unwrap_or_default()146
.iter()147
.filter(|state| self.cached_chat_hidden_by_time(state))148
.map(|state| state.id.as_str())149
.collect();144
let now = Utc::now();150
let now = Utc::now();145
let hidden: Vec<String> = self.with_locally_hidden(|locally| {151
let hidden: Vec<String> = self.with_locally_hidden(|locally| {146
reported152
let mut hidden: Vec<String> = reported147
.iter()153
.iter()148
.filter(|chat_id| locally.reported_hidden(chat_id, now))154
.filter(|chat_id| locally.reported_hidden(chat_id, now))149
.map(|chat_id| (*chat_id).to_owned())155
.map(|chat_id| (*chat_id).to_owned())150
.collect()156
.collect();157
hidden.extend(158
hidden_by_time159
.iter()160
.filter(|chat_id| !locally.unhide_override_active(chat_id, now))161
.map(|chat_id| (*chat_id).to_owned()),162
);163
hidden151
})?;164
})?;152
self.store.remove_chats(&hidden)?;165
self.store.remove_chats(&hidden)?;153
Ok(())166
Ok(())154
}167
}155
168
169
fn cached_chat_hidden_by_time(&self, state: &ConversationState) -> bool {170
let Some(hidden_at_ms) = state.hidden_at_ms else {171
return false;172
};173
match self.store.chat(&state.id) {174
Ok(Some(chat)) => chat175
.last_message_at176
.is_none_or(|last| last.timestamp_millis() <= hidden_at_ms),177
_ => false,178
}179
}180
156
async fn refresh_app_channel_horizon(&self) -> i64 {181
async fn refresh_app_channel_horizon(&self) -> i64 {157
match self.remote.app_consumption_horizon().await {182
match self.remote.app_consumption_horizon().await {158
Ok(horizon) => {183
Ok(horizon) => {