Skip to content

Commit 62137e5

Browse files
Hywanbnjbvr
authored andcommitted
fix(sdk): SlidingSyncBuilder restores the rooms from the cache.
This patch fixes a bug where rooms stored in the sliding sync cache aren't restored by the `SlidingSyncBuilder`. This patch also removes `SlidingSyncBuilder::rooms` fields which was used but never modified. It's dead code.
1 parent 84dfb78 commit 62137e5

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

crates/matrix-sdk/src/sliding_sync/builder.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use super::{
2121
cache::{format_storage_key_prefix, restore_sliding_sync_state},
2222
sticky_parameters::SlidingSyncStickyManager,
2323
Error, SlidingSync, SlidingSyncInner, SlidingSyncListBuilder, SlidingSyncPositionMarkers,
24-
SlidingSyncRoom,
2524
};
2625
use crate::{sliding_sync::SlidingSyncStickyParameters, Client, Result};
2726

@@ -38,7 +37,6 @@ pub struct SlidingSyncBuilder {
3837
lists: Vec<SlidingSyncListBuilder>,
3938
extensions: Option<ExtensionsConfig>,
4039
subscriptions: BTreeMap<OwnedRoomId, v4::RoomSubscription>,
41-
rooms: BTreeMap<OwnedRoomId, SlidingSyncRoom>,
4240
poll_timeout: Duration,
4341
network_timeout: Duration,
4442
#[cfg(feature = "e2e-encryption")]
@@ -60,7 +58,6 @@ impl SlidingSyncBuilder {
6058
lists: Vec::new(),
6159
extensions: None,
6260
subscriptions: BTreeMap::new(),
63-
rooms: BTreeMap::new(),
6461
poll_timeout: Duration::from_secs(30),
6562
network_timeout: Duration::from_secs(30),
6663
#[cfg(feature = "e2e-encryption")]
@@ -254,23 +251,23 @@ impl SlidingSyncBuilder {
254251
let restored_fields =
255252
restore_sliding_sync_state(&client, &self.storage_key, &lists).await?;
256253

257-
let (delta_token, pos) = if let Some(fields) = restored_fields {
254+
let (delta_token, pos, rooms) = if let Some(fields) = restored_fields {
258255
#[cfg(feature = "e2e-encryption")]
259256
let pos = if self.share_pos { fields.pos } else { None };
260257
#[cfg(not(feature = "e2e-encryption"))]
261258
let pos = None;
262259

263-
(fields.delta_token, pos)
260+
(fields.delta_token, pos, fields.rooms)
264261
} else {
265-
(None, None)
262+
(None, None, BTreeMap::new())
266263
};
267264

268265
#[cfg(feature = "e2e-encryption")]
269266
let share_pos = self.share_pos;
270267
#[cfg(not(feature = "e2e-encryption"))]
271268
let share_pos = false;
272269

273-
let rooms = AsyncRwLock::new(self.rooms);
270+
let rooms = AsyncRwLock::new(rooms);
274271
let lists = AsyncRwLock::new(lists);
275272

276273
// Use the configured sliding sync proxy, or if not set, try to use the one

0 commit comments

Comments
 (0)