mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-13 18:45:44 -04:00
This bug has been found by @bnjbvr, all the credits go to him. I've just added some comments around his code. Prior to this patch, the room unsubscription buffer (`SlidingSync::room_unsubscriptions`) was reset before the request was sent. So if something went wrong, the next request would not include the room unsubscriptions. This patch updates this behavior. First, it replaces `Vec` by `HashSet` to avoid a O(n^2) look up. Second, a copy of room unsubscriptions used by the request is kept, so that it can be used to cherry-pick which room unsubscription to remove from the buffer once a response from the server is received. It's important to not clear the entire room unsubscriptions buffer as more unsubscriptions could have been inserted meanwhile.