Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add add_cached_list to SlidingSyncBuilder and SlidingSync #1876

Merged
merged 18 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/matrix-sdk/src/sliding_sync/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ impl SlidingSyncBuilder {
/// Enroll the list in caching, reloads it from the cache if possible, and
/// adds it to the list of lists.
///
/// This will raise an error if a [`storage_key()`] was not set, or if there
/// was a I/O error reading from the cache.
/// This will raise an error if a [`Self::storage_key()`] was not set, or if
bnjbvr marked this conversation as resolved.
Show resolved Hide resolved
/// there was a I/O error reading from the cache.
///
/// Replace any list with the same name.
pub async fn add_cached_list(mut self, mut list: SlidingSyncListBuilder) -> Result<Self> {
Expand Down
6 changes: 3 additions & 3 deletions crates/matrix-sdk/src/sliding_sync/list/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use std::{
use eyeball::unique::Observable;
use eyeball_im::ObservableVector;
use imbl::Vector;
use ruma::{api::client::sync::sync_events::v4, events::StateEventType, OwnedRoomId, UInt};
use ruma::{api::client::sync::sync_events::v4, events::StateEventType, OwnedRoomId};
use tokio::sync::mpsc::Sender;

use super::{
super::SlidingSyncInternalMessage, SlidingSyncList, SlidingSyncListCachePolicy,
super::SlidingSyncInternalMessage, Bound, SlidingSyncList, SlidingSyncListCachePolicy,
SlidingSyncListInner, SlidingSyncListRequestGenerator, SlidingSyncMode, SlidingSyncState,
};
use crate::{
Expand Down Expand Up @@ -50,7 +50,7 @@ pub struct SlidingSyncListBuilder {
filters: Option<v4::SyncRequestListFilters>,
timeline_limit: Option<Bound>,
name: String,
ranges: Vec<(UInt, UInt)>,
ranges: Vec<RangeInclusive<Bound>>,

/// Should this list be cached and reloaded from the cache?
cache_policy: SlidingSyncListCachePolicy,
Expand Down
4 changes: 4 additions & 0 deletions crates/matrix-sdk/src/sliding_sync/list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ pub(crate) enum SlidingSyncListCachePolicy {
Disabled,
}

/// The type used to express natural bounds (including but not limited to:
/// ranges, timeline limit) in the sliding sync SDK.
pub type Bound = u32;

/// Holding a specific filtered list within the concept of sliding sync.
///
/// It is OK to clone this type as much as you need: cloning it is cheap.
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk/src/sliding_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl SlidingSync {

/// Add a list that will be cached and reloaded from the cache.
///
/// This will raise an error if a [`storage_key()`] was not set, or if there
/// This will raise an error if a storage key was not set, or if there
/// was a I/O error reading from the cache.
///
/// The rest of the semantics is the same as [`Self::add_list`].
Expand Down