doc(sdk): Update documentation according to last commits.

This commit is contained in:
Ivan Enderlin
2023-05-17 15:35:21 +02:00
parent 63feec1433
commit f8e12f6aaf

View File

@@ -74,7 +74,7 @@ are **inclusive**) like so:
use ruma::{assign, api::client::sync::sync_events::v4};
let list_builder = SlidingSyncList::builder("main_list")
.sync_mode(SlidingSyncMode::Selective)
.sync_mode(SlidingSyncMode::new_selective())
.filters(Some(assign!(
v4::SyncRequestListFilters::default(), { is_dm: Some(true)}
)))
@@ -121,16 +121,11 @@ background though. For that, the client implementation offers to run lists
in two additional full-sync-modes, which require additional configuration:
- [`SlidingSyncMode::Paging`]: Pages through the entire list of
rooms one request at a time asking for the next `full_sync_batch_size` number of
rooms up to the end or `full_sync_maximum_number_of_rooms_to_fetch` if configured
- [`SlidingSyncMode::Growing`]: Grows the window by `full_sync_batch_size` on
every request till all rooms or until `full_sync_maximum_number_of_rooms_to_fetch` of rooms are in list.
For both, one should configure
[`full_sync_batch_size`](SlidingSyncListBuilder::full_sync_batch_size) and optionally
[`full_sync_maximum_number_of_rooms_to_fetch`](SlidingSyncListBuilder::full_sync_maximum_number_of_rooms_to_fetch)
on the [`SlidingSyncListBuilder`]. Both full-sync lists will notice if the number of rooms
increased at runtime and will attempt to catch up to that (barring the `limit`).
rooms one request at a time asking for the next `batch_size` number of
rooms up to the end or `maximum_number_of_rooms_to_fetch` if configured
- [`SlidingSyncMode::Growing`]: Grows the window by `batch_size` on every
request till all rooms or until `maximum_number_of_rooms_to_fetch` of rooms
are in list.
## Rooms
@@ -428,16 +423,14 @@ let sliding_sync_builder = client
.storage_key(Some("example-cache".to_owned())); // we want these to be loaded from and stored into the persistent storage
let full_sync_list = SlidingSyncList::builder(&full_sync_list_name)
.sync_mode(SlidingSyncMode::Growing) // sync up by growing the window
.sync_mode(SlidingSyncMode::new_growing(50, Some(500))) // sync up by growing the window of 50 rooms, up to 500 rooms
.sort(vec!["by_recency".to_owned()]) // ordered by most recent
.required_state(vec![
(StateEventType::RoomEncryption, "".to_owned())
]) // only want to know if the room is encrypted
.full_sync_batch_size(50) // grow the window by 50 items at a time
.full_sync_maximum_number_of_rooms_to_fetch(500); // only sync up the top 500 rooms
let active_list = SlidingSyncList::builder(&active_list_name) // the active window
.sync_mode(SlidingSyncMode::Selective) // sync up the specific range only
.sync_mode(SlidingSyncMode::new_selective()) // sync up the specific range only
.set_range(0u32..=9) // only the top 10 items
.sort(vec!["by_recency".to_owned()]) // last active
.timeline_limit(5u32) // add the last 5 timeline items for room preview and faster timeline loading