Watch
0
0
Fork
You've already forked hyperhive
0

hive-matrix: the unread sweep after a sync looks at the rooms the sync touched, not at every joined room

Each room the sweep looks at costs a live /messages fetch of up to 50 events, and the sweep ran for every joined room after every sync response, so a busy account fetched thousands of times an hour whatever the sync itself carried. The sweep now covers the rooms the response names (sliding sync's UpdateSummary rooms, classic's joined rooms), with a full pass first and every five minutes.
This commit is contained in:
damocles 2026-11-11 16:53:43 +01:00 • committed by mara
commit b89ca3955a

View file

@ -1253,10 +1253,21 @@ pub async fn collect_unread(client: &Client) -> Vec<crate::protocol::RoomUnread>
#[must_use]
pub async fn collect_unread_with_ids(
client: &Client,
) -> Vec<(matrix_sdk::ruma::OwnedRoomId, crate::protocol::RoomUnread)> {
collect_unread_in(client, client.joined_rooms()).await
}
/// [`collect_unread_with_ids`] over just `rooms`. Each room costs one live
/// `/messages` fetch (see `recent_events`), so the post-sync sweep passes
/// only the rooms the sync touched.
#[must_use]
pub async fn collect_unread_in(
client: &Client,
rooms: Vec<matrix_sdk::Room>,
) -> Vec<(matrix_sdk::ruma::OwnedRoomId, crate::protocol::RoomUnread)> {
use crate::protocol::RoomUnread;
let mut result = Vec::new();
for room in client.joined_rooms() {
for room in rooms {
let Some((_, sender, body)) = room_unread_state(client, &room).await else {
continue;
};