mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-05 14:35:20 -04:00
fix(sdk): Rename SlidingSyncView to SlidingSyncList.
The specification describes “list”, not “view”. Consistency is important, so let's rename this type!
This commit is contained in:
@@ -53,7 +53,7 @@ enum SlidingSyncMode {
|
||||
"Selective",
|
||||
};
|
||||
|
||||
callback interface SlidingSyncViewStateObserver {
|
||||
callback interface SlidingSyncListStateObserver {
|
||||
void did_receive_update(SlidingSyncState new_state);
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ interface RoomListEntry {
|
||||
};
|
||||
|
||||
[Enum]
|
||||
interface SlidingSyncViewRoomsListDiff {
|
||||
interface SlidingSyncListRoomsListDiff {
|
||||
Append(sequence<RoomListEntry> values);
|
||||
Insert(u32 index, RoomListEntry value);
|
||||
Set(u32 index, RoomListEntry value);
|
||||
@@ -78,36 +78,36 @@ interface SlidingSyncViewRoomsListDiff {
|
||||
Reset(sequence<RoomListEntry> values);
|
||||
};
|
||||
|
||||
callback interface SlidingSyncViewRoomListObserver {
|
||||
void did_receive_update(SlidingSyncViewRoomsListDiff diff);
|
||||
callback interface SlidingSyncListRoomListObserver {
|
||||
void did_receive_update(SlidingSyncListRoomsListDiff diff);
|
||||
};
|
||||
|
||||
callback interface SlidingSyncViewRoomsCountObserver {
|
||||
callback interface SlidingSyncListRoomsCountObserver {
|
||||
void did_receive_update(u32 count);
|
||||
};
|
||||
|
||||
callback interface SlidingSyncViewRoomItemsObserver {
|
||||
callback interface SlidingSyncListRoomItemsObserver {
|
||||
void did_receive_update();
|
||||
};
|
||||
|
||||
interface SlidingSyncViewBuilder {
|
||||
interface SlidingSyncListBuilder {
|
||||
constructor();
|
||||
|
||||
[Self=ByArc]
|
||||
SlidingSyncViewBuilder sync_mode(SlidingSyncMode mode);
|
||||
SlidingSyncListBuilder sync_mode(SlidingSyncMode mode);
|
||||
|
||||
[Self=ByArc]
|
||||
SlidingSyncViewBuilder send_updates_for_items(boolean enable);
|
||||
SlidingSyncListBuilder send_updates_for_items(boolean enable);
|
||||
|
||||
[Throws=ClientError, Self=ByArc]
|
||||
SlidingSyncView build();
|
||||
SlidingSyncList build();
|
||||
};
|
||||
|
||||
interface SlidingSyncView {
|
||||
TaskHandle observe_room_list(SlidingSyncViewRoomListObserver observer);
|
||||
TaskHandle observe_rooms_count(SlidingSyncViewRoomsCountObserver observer);
|
||||
TaskHandle observe_state(SlidingSyncViewStateObserver observer);
|
||||
TaskHandle observe_room_items(SlidingSyncViewRoomItemsObserver observer);
|
||||
interface SlidingSyncList {
|
||||
TaskHandle observe_room_list(SlidingSyncListRoomListObserver observer);
|
||||
TaskHandle observe_rooms_count(SlidingSyncListRoomsCountObserver observer);
|
||||
TaskHandle observe_state(SlidingSyncListStateObserver observer);
|
||||
TaskHandle observe_room_items(SlidingSyncListRoomItemsObserver observer);
|
||||
};
|
||||
|
||||
interface SlidingSyncRoom {
|
||||
|
||||
@@ -86,8 +86,8 @@ mod uniffi_types {
|
||||
session_verification::{SessionVerificationController, SessionVerificationEmoji},
|
||||
sliding_sync::{
|
||||
RequiredState, RoomListEntry, SlidingSync, SlidingSyncBuilder,
|
||||
SlidingSyncRequestListFilters, SlidingSyncRoom, SlidingSyncView,
|
||||
SlidingSyncViewBuilder, TaskHandle, UnreadNotificationsCount,
|
||||
SlidingSyncRequestListFilters, SlidingSyncRoom, SlidingSyncList,
|
||||
SlidingSyncListBuilder, TaskHandle, UnreadNotificationsCount,
|
||||
},
|
||||
timeline::{
|
||||
AudioInfo, AudioMessageContent, EmoteMessageContent, EncryptedMessage, EventSendState,
|
||||
|
||||
@@ -282,7 +282,7 @@ impl From<matrix_sdk::UpdateSummary> for UpdateSummary {
|
||||
}
|
||||
}
|
||||
|
||||
pub enum SlidingSyncViewRoomsListDiff {
|
||||
pub enum SlidingSyncListRoomsListDiff {
|
||||
Append { values: Vec<RoomListEntry> },
|
||||
Insert { index: u32, value: RoomListEntry },
|
||||
Set { index: u32, value: RoomListEntry },
|
||||
@@ -295,33 +295,33 @@ pub enum SlidingSyncViewRoomsListDiff {
|
||||
Reset { values: Vec<RoomListEntry> },
|
||||
}
|
||||
|
||||
impl From<VectorDiff<MatrixRoomEntry>> for SlidingSyncViewRoomsListDiff {
|
||||
impl From<VectorDiff<MatrixRoomEntry>> for SlidingSyncListRoomsListDiff {
|
||||
fn from(other: VectorDiff<MatrixRoomEntry>) -> Self {
|
||||
match other {
|
||||
VectorDiff::Append { values } => SlidingSyncViewRoomsListDiff::Append {
|
||||
VectorDiff::Append { values } => SlidingSyncListRoomsListDiff::Append {
|
||||
values: values.into_iter().map(|e| (&e).into()).collect(),
|
||||
},
|
||||
VectorDiff::Insert { index, value } => {
|
||||
SlidingSyncViewRoomsListDiff::Insert { index: index as u32, value: (&value).into() }
|
||||
SlidingSyncListRoomsListDiff::Insert { index: index as u32, value: (&value).into() }
|
||||
}
|
||||
VectorDiff::Set { index, value } => {
|
||||
SlidingSyncViewRoomsListDiff::Set { index: index as u32, value: (&value).into() }
|
||||
SlidingSyncListRoomsListDiff::Set { index: index as u32, value: (&value).into() }
|
||||
}
|
||||
VectorDiff::Remove { index } => {
|
||||
SlidingSyncViewRoomsListDiff::Remove { index: index as u32 }
|
||||
SlidingSyncListRoomsListDiff::Remove { index: index as u32 }
|
||||
}
|
||||
VectorDiff::PushBack { value } => {
|
||||
SlidingSyncViewRoomsListDiff::PushBack { value: (&value).into() }
|
||||
SlidingSyncListRoomsListDiff::PushBack { value: (&value).into() }
|
||||
}
|
||||
VectorDiff::PushFront { value } => {
|
||||
SlidingSyncViewRoomsListDiff::PushFront { value: (&value).into() }
|
||||
SlidingSyncListRoomsListDiff::PushFront { value: (&value).into() }
|
||||
}
|
||||
VectorDiff::PopBack => SlidingSyncViewRoomsListDiff::PopBack,
|
||||
VectorDiff::PopFront => SlidingSyncViewRoomsListDiff::PopFront,
|
||||
VectorDiff::Clear => SlidingSyncViewRoomsListDiff::Clear,
|
||||
VectorDiff::PopBack => SlidingSyncListRoomsListDiff::PopBack,
|
||||
VectorDiff::PopFront => SlidingSyncListRoomsListDiff::PopFront,
|
||||
VectorDiff::Clear => SlidingSyncListRoomsListDiff::Clear,
|
||||
VectorDiff::Reset { values } => {
|
||||
warn!("Room list subscriber lagged behind and was reset");
|
||||
SlidingSyncViewRoomsListDiff::Reset {
|
||||
SlidingSyncListRoomsListDiff::Reset {
|
||||
values: values.into_iter().map(|e| (&e).into()).collect(),
|
||||
}
|
||||
}
|
||||
@@ -348,25 +348,25 @@ impl From<&MatrixRoomEntry> for RoomListEntry {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait SlidingSyncViewRoomItemsObserver: Sync + Send {
|
||||
pub trait SlidingSyncListRoomItemsObserver: Sync + Send {
|
||||
fn did_receive_update(&self);
|
||||
}
|
||||
|
||||
pub trait SlidingSyncViewRoomListObserver: Sync + Send {
|
||||
fn did_receive_update(&self, diff: SlidingSyncViewRoomsListDiff);
|
||||
pub trait SlidingSyncListRoomListObserver: Sync + Send {
|
||||
fn did_receive_update(&self, diff: SlidingSyncListRoomsListDiff);
|
||||
}
|
||||
|
||||
pub trait SlidingSyncViewRoomsCountObserver: Sync + Send {
|
||||
pub trait SlidingSyncListRoomsCountObserver: Sync + Send {
|
||||
fn did_receive_update(&self, new_count: u32);
|
||||
}
|
||||
|
||||
pub trait SlidingSyncViewStateObserver: Sync + Send {
|
||||
pub trait SlidingSyncListStateObserver: Sync + Send {
|
||||
fn did_receive_update(&self, new_state: SlidingSyncState);
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SlidingSyncViewBuilder {
|
||||
inner: matrix_sdk::SlidingSyncViewBuilder,
|
||||
pub struct SlidingSyncListBuilder {
|
||||
inner: matrix_sdk::SlidingSyncListBuilder,
|
||||
}
|
||||
|
||||
#[derive(uniffi::Record)]
|
||||
@@ -404,9 +404,9 @@ impl From<SlidingSyncRequestListFilters> for SyncRequestListFilters {
|
||||
}
|
||||
}
|
||||
|
||||
impl SlidingSyncViewBuilder {
|
||||
impl SlidingSyncListBuilder {
|
||||
pub fn new() -> Self {
|
||||
Self { inner: matrix_sdk::SlidingSyncView::builder() }
|
||||
Self { inner: matrix_sdk::SlidingSyncList::builder() }
|
||||
}
|
||||
|
||||
pub fn sync_mode(self: Arc<Self>, mode: SlidingSyncMode) -> Arc<Self> {
|
||||
@@ -427,14 +427,14 @@ impl SlidingSyncViewBuilder {
|
||||
Arc::new(builder)
|
||||
}
|
||||
|
||||
pub fn build(self: Arc<Self>) -> anyhow::Result<Arc<SlidingSyncView>> {
|
||||
pub fn build(self: Arc<Self>) -> anyhow::Result<Arc<SlidingSyncList>> {
|
||||
let builder = unwrap_or_clone_arc(self);
|
||||
Ok(Arc::new(builder.inner.build()?.into()))
|
||||
}
|
||||
}
|
||||
|
||||
#[uniffi::export]
|
||||
impl SlidingSyncViewBuilder {
|
||||
impl SlidingSyncListBuilder {
|
||||
pub fn sort(self: Arc<Self>, sort: Vec<String>) -> Arc<Self> {
|
||||
let mut builder = unwrap_or_clone_arc(self);
|
||||
builder.inner = builder.inner.sort(sort);
|
||||
@@ -511,20 +511,20 @@ impl SlidingSyncViewBuilder {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SlidingSyncView {
|
||||
inner: matrix_sdk::SlidingSyncView,
|
||||
pub struct SlidingSyncList {
|
||||
inner: matrix_sdk::SlidingSyncList,
|
||||
}
|
||||
|
||||
impl From<matrix_sdk::SlidingSyncView> for SlidingSyncView {
|
||||
fn from(inner: matrix_sdk::SlidingSyncView) -> Self {
|
||||
SlidingSyncView { inner }
|
||||
impl From<matrix_sdk::SlidingSyncList> for SlidingSyncList {
|
||||
fn from(inner: matrix_sdk::SlidingSyncList) -> Self {
|
||||
SlidingSyncList { inner }
|
||||
}
|
||||
}
|
||||
|
||||
impl SlidingSyncView {
|
||||
impl SlidingSyncList {
|
||||
pub fn observe_state(
|
||||
&self,
|
||||
observer: Box<dyn SlidingSyncViewStateObserver>,
|
||||
observer: Box<dyn SlidingSyncListStateObserver>,
|
||||
) -> Arc<TaskHandle> {
|
||||
let mut state_stream = self.inner.state_stream();
|
||||
|
||||
@@ -539,7 +539,7 @@ impl SlidingSyncView {
|
||||
|
||||
pub fn observe_room_list(
|
||||
&self,
|
||||
observer: Box<dyn SlidingSyncViewRoomListObserver>,
|
||||
observer: Box<dyn SlidingSyncListRoomListObserver>,
|
||||
) -> Arc<TaskHandle> {
|
||||
let mut rooms_list_stream = self.inner.rooms_list_stream();
|
||||
|
||||
@@ -554,7 +554,7 @@ impl SlidingSyncView {
|
||||
|
||||
pub fn observe_room_items(
|
||||
&self,
|
||||
observer: Box<dyn SlidingSyncViewRoomItemsObserver>,
|
||||
observer: Box<dyn SlidingSyncListRoomItemsObserver>,
|
||||
) -> Arc<TaskHandle> {
|
||||
let mut rooms_updated =
|
||||
Observable::subscribe(&self.inner.rooms_updated_broadcast.read().unwrap());
|
||||
@@ -569,7 +569,7 @@ impl SlidingSyncView {
|
||||
|
||||
pub fn observe_rooms_count(
|
||||
&self,
|
||||
observer: Box<dyn SlidingSyncViewRoomsCountObserver>,
|
||||
observer: Box<dyn SlidingSyncListRoomsCountObserver>,
|
||||
) -> Arc<TaskHandle> {
|
||||
let mut rooms_count_stream = self.inner.rooms_count_stream();
|
||||
|
||||
@@ -584,7 +584,7 @@ impl SlidingSyncView {
|
||||
}
|
||||
|
||||
#[uniffi::export]
|
||||
impl SlidingSyncView {
|
||||
impl SlidingSyncList {
|
||||
/// Get the current list of rooms
|
||||
pub fn current_rooms_list(&self) -> Vec<RoomListEntry> {
|
||||
self.inner.rooms_list()
|
||||
@@ -709,16 +709,16 @@ impl SlidingSync {
|
||||
#[uniffi::export]
|
||||
impl SlidingSync {
|
||||
#[allow(clippy::significant_drop_in_scrutinee)]
|
||||
pub fn get_view(&self, name: String) -> Option<Arc<SlidingSyncView>> {
|
||||
self.inner.view(&name).map(|inner| Arc::new(SlidingSyncView { inner }))
|
||||
pub fn get_view(&self, name: String) -> Option<Arc<SlidingSyncList>> {
|
||||
self.inner.view(&name).map(|inner| Arc::new(SlidingSyncList { inner }))
|
||||
}
|
||||
|
||||
pub fn add_view(&self, view: Arc<SlidingSyncView>) -> Option<Arc<SlidingSyncView>> {
|
||||
self.inner.add_view(view.inner.clone()).map(|inner| Arc::new(SlidingSyncView { inner }))
|
||||
pub fn add_view(&self, view: Arc<SlidingSyncList>) -> Option<Arc<SlidingSyncList>> {
|
||||
self.inner.add_view(view.inner.clone()).map(|inner| Arc::new(SlidingSyncList { inner }))
|
||||
}
|
||||
|
||||
pub fn pop_view(&self, name: String) -> Option<Arc<SlidingSyncView>> {
|
||||
self.inner.pop_view(&name).map(|inner| Arc::new(SlidingSyncView { inner }))
|
||||
pub fn pop_view(&self, name: String) -> Option<Arc<SlidingSyncList>> {
|
||||
self.inner.pop_view(&name).map(|inner| Arc::new(SlidingSyncList { inner }))
|
||||
}
|
||||
|
||||
pub fn add_common_extensions(&self) {
|
||||
@@ -810,7 +810,7 @@ impl SlidingSyncBuilder {
|
||||
Arc::new(builder)
|
||||
}
|
||||
|
||||
pub fn add_view(self: Arc<Self>, v: Arc<SlidingSyncView>) -> Arc<Self> {
|
||||
pub fn add_view(self: Arc<Self>, v: Arc<SlidingSyncList>) -> Arc<Self> {
|
||||
let mut builder = unwrap_or_clone_arc(self);
|
||||
let view = unwrap_or_clone_arc(v);
|
||||
builder.inner = builder.inner.add_view(view.inner);
|
||||
|
||||
@@ -59,7 +59,7 @@ pub use ruma::{IdParseError, OwnedServerName, ServerName};
|
||||
#[cfg(feature = "experimental-sliding-sync")]
|
||||
pub use sliding_sync::{
|
||||
RoomListEntry, SlidingSync, SlidingSyncBuilder, SlidingSyncMode, SlidingSyncRoom,
|
||||
SlidingSyncState, SlidingSyncView, SlidingSyncViewBuilder, UpdateSummary,
|
||||
SlidingSyncState, SlidingSyncList, SlidingSyncListBuilder, UpdateSummary,
|
||||
};
|
||||
|
||||
#[cfg(any(test, feature = "testing"))]
|
||||
|
||||
@@ -16,8 +16,8 @@ use tracing::trace;
|
||||
use url::Url;
|
||||
|
||||
use super::{
|
||||
Error, FrozenSlidingSync, FrozenSlidingSyncView, SlidingSync, SlidingSyncRoom, SlidingSyncView,
|
||||
SlidingSyncViewBuilder,
|
||||
Error, FrozenSlidingSync, FrozenSlidingSyncList, SlidingSync, SlidingSyncRoom, SlidingSyncList,
|
||||
SlidingSyncListBuilder,
|
||||
};
|
||||
use crate::{Client, Result};
|
||||
|
||||
@@ -30,7 +30,7 @@ pub struct SlidingSyncBuilder {
|
||||
storage_key: Option<String>,
|
||||
homeserver: Option<Url>,
|
||||
client: Option<Client>,
|
||||
views: BTreeMap<String, SlidingSyncView>,
|
||||
views: BTreeMap<String, SlidingSyncList>,
|
||||
extensions: Option<ExtensionsConfig>,
|
||||
subscriptions: BTreeMap<OwnedRoomId, v4::RoomSubscription>,
|
||||
}
|
||||
@@ -76,7 +76,7 @@ impl SlidingSyncBuilder {
|
||||
/// Convenience function to add a full-sync view to the builder
|
||||
pub fn add_fullsync_view(self) -> Self {
|
||||
self.add_view(
|
||||
SlidingSyncViewBuilder::default_with_fullsync()
|
||||
SlidingSyncListBuilder::default_with_fullsync()
|
||||
.build()
|
||||
.expect("Building default full sync view doesn't fail"),
|
||||
)
|
||||
@@ -103,7 +103,7 @@ impl SlidingSyncBuilder {
|
||||
/// Add the given view to the views.
|
||||
///
|
||||
/// Replace any view with the name.
|
||||
pub fn add_view(mut self, v: SlidingSyncView) -> Self {
|
||||
pub fn add_view(mut self, v: SlidingSyncList) -> Self {
|
||||
self.views.insert(v.name.clone(), v);
|
||||
self
|
||||
}
|
||||
@@ -242,12 +242,12 @@ impl SlidingSyncBuilder {
|
||||
.store()
|
||||
.get_custom_value(format!("{storage_key}::{name}").as_bytes())
|
||||
.await?
|
||||
.map(|v| serde_json::from_slice::<FrozenSlidingSyncView>(&v))
|
||||
.map(|v| serde_json::from_slice::<FrozenSlidingSyncList>(&v))
|
||||
.transpose()?
|
||||
{
|
||||
trace!(name, "frozen for view found");
|
||||
|
||||
let FrozenSlidingSyncView { rooms_count, rooms_list, rooms } = frozen_view;
|
||||
let FrozenSlidingSyncList { rooms_count, rooms_list, rooms } = frozen_view;
|
||||
view.set_from_cold(rooms_count, rooms_list);
|
||||
|
||||
for (key, frozen_room) in rooms.into_iter() {
|
||||
|
||||
@@ -24,7 +24,6 @@ use crate::Result;
|
||||
/// Holding a specific filtered view within the concept of sliding sync.
|
||||
/// Main entrypoint to the SlidingSync
|
||||
///
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use futures::executor::block_on;
|
||||
/// # use matrix_sdk::Client;
|
||||
@@ -39,7 +38,7 @@ use crate::Result;
|
||||
/// # });
|
||||
/// ```
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SlidingSyncView {
|
||||
pub struct SlidingSyncList {
|
||||
/// Which SlidingSyncMode to start this view under
|
||||
sync_mode: SlidingSyncMode,
|
||||
|
||||
@@ -92,7 +91,7 @@ pub struct SlidingSyncView {
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub(super) struct FrozenSlidingSyncView {
|
||||
pub(super) struct FrozenSlidingSyncList {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub(super) rooms_count: Option<u32>,
|
||||
#[serde(default, skip_serializing_if = "Vector::is_empty")]
|
||||
@@ -101,9 +100,9 @@ pub(super) struct FrozenSlidingSyncView {
|
||||
pub(super) rooms: BTreeMap<OwnedRoomId, FrozenSlidingSyncRoom>,
|
||||
}
|
||||
|
||||
impl FrozenSlidingSyncView {
|
||||
impl FrozenSlidingSyncList {
|
||||
pub(super) fn freeze(
|
||||
source_view: &SlidingSyncView,
|
||||
source_view: &SlidingSyncList,
|
||||
rooms_map: &BTreeMap<OwnedRoomId, SlidingSyncRoom>,
|
||||
) -> Self {
|
||||
let mut rooms = BTreeMap::new();
|
||||
@@ -118,7 +117,7 @@ impl FrozenSlidingSyncView {
|
||||
|
||||
rooms_list.push_back(entry.freeze());
|
||||
}
|
||||
FrozenSlidingSyncView {
|
||||
FrozenSlidingSyncList {
|
||||
rooms_count: **source_view.rooms_count.read().unwrap(),
|
||||
rooms_list,
|
||||
rooms,
|
||||
@@ -126,7 +125,7 @@ impl FrozenSlidingSyncView {
|
||||
}
|
||||
}
|
||||
|
||||
impl SlidingSyncView {
|
||||
impl SlidingSyncList {
|
||||
pub(crate) fn set_from_cold(
|
||||
&mut self,
|
||||
rooms_count: Option<u32>,
|
||||
@@ -141,13 +140,13 @@ impl SlidingSyncView {
|
||||
lock.append(rooms_list);
|
||||
}
|
||||
|
||||
/// Create a new [`SlidingSyncViewBuilder`].
|
||||
pub fn builder() -> SlidingSyncViewBuilder {
|
||||
SlidingSyncViewBuilder::new()
|
||||
/// Create a new [`SlidingSyncListBuilder`].
|
||||
pub fn builder() -> SlidingSyncListBuilder {
|
||||
SlidingSyncListBuilder::new()
|
||||
}
|
||||
|
||||
/// Return a builder with the same settings as before
|
||||
pub fn new_builder(&self) -> SlidingSyncViewBuilder {
|
||||
pub fn new_builder(&self) -> SlidingSyncListBuilder {
|
||||
Self::builder()
|
||||
.name(&self.name)
|
||||
.sync_mode(self.sync_mode.clone())
|
||||
@@ -385,15 +384,15 @@ impl SlidingSyncView {
|
||||
Ok(changed)
|
||||
}
|
||||
|
||||
pub(super) fn request_generator(&self) -> SlidingSyncViewRequestGenerator {
|
||||
pub(super) fn request_generator(&self) -> SlidingSyncListRequestGenerator {
|
||||
match &self.sync_mode {
|
||||
SlidingSyncMode::PagingFullSync => {
|
||||
SlidingSyncViewRequestGenerator::new_with_paging_syncup(self.clone())
|
||||
SlidingSyncListRequestGenerator::new_with_paging_syncup(self.clone())
|
||||
}
|
||||
SlidingSyncMode::GrowingFullSync => {
|
||||
SlidingSyncViewRequestGenerator::new_with_growing_syncup(self.clone())
|
||||
SlidingSyncListRequestGenerator::new_with_growing_syncup(self.clone())
|
||||
}
|
||||
SlidingSyncMode::Selective => SlidingSyncViewRequestGenerator::new_live(self.clone()),
|
||||
SlidingSyncMode::Selective => SlidingSyncListRequestGenerator::new_live(self.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -401,9 +400,9 @@ impl SlidingSyncView {
|
||||
/// the default name for the full sync view
|
||||
pub const FULL_SYNC_VIEW_NAME: &str = "full-sync";
|
||||
|
||||
/// Builder for [`SlidingSyncView`].
|
||||
/// Builder for [`SlidingSyncList`].
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SlidingSyncViewBuilder {
|
||||
pub struct SlidingSyncListBuilder {
|
||||
sync_mode: SlidingSyncMode,
|
||||
sort: Vec<String>,
|
||||
required_state: Vec<(StateEventType, String)>,
|
||||
@@ -419,7 +418,7 @@ pub struct SlidingSyncViewBuilder {
|
||||
ranges: Vec<(UInt, UInt)>,
|
||||
}
|
||||
|
||||
impl SlidingSyncViewBuilder {
|
||||
impl SlidingSyncListBuilder {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
sync_mode: SlidingSyncMode::default(),
|
||||
@@ -533,11 +532,11 @@ impl SlidingSyncViewBuilder {
|
||||
}
|
||||
|
||||
/// Build the view
|
||||
pub fn build(self) -> Result<SlidingSyncView> {
|
||||
pub fn build(self) -> Result<SlidingSyncList> {
|
||||
let mut rooms_list = ObservableVector::new();
|
||||
rooms_list.append(self.rooms_list);
|
||||
|
||||
Ok(SlidingSyncView {
|
||||
Ok(SlidingSyncList {
|
||||
sync_mode: self.sync_mode,
|
||||
sort: self.sort,
|
||||
required_state: self.required_state,
|
||||
@@ -557,20 +556,20 @@ impl SlidingSyncViewBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
enum InnerSlidingSyncViewRequestGenerator {
|
||||
enum InnerSlidingSyncListRequestGenerator {
|
||||
GrowingFullSync { position: u32, batch_size: u32, limit: Option<u32>, live: bool },
|
||||
PagingFullSync { position: u32, batch_size: u32, limit: Option<u32>, live: bool },
|
||||
Live,
|
||||
}
|
||||
|
||||
pub(super) struct SlidingSyncViewRequestGenerator {
|
||||
view: SlidingSyncView,
|
||||
pub(super) struct SlidingSyncListRequestGenerator {
|
||||
view: SlidingSyncList,
|
||||
ranges: Vec<(usize, usize)>,
|
||||
inner: InnerSlidingSyncViewRequestGenerator,
|
||||
inner: InnerSlidingSyncListRequestGenerator,
|
||||
}
|
||||
|
||||
impl SlidingSyncViewRequestGenerator {
|
||||
fn new_with_paging_syncup(view: SlidingSyncView) -> Self {
|
||||
impl SlidingSyncListRequestGenerator {
|
||||
fn new_with_paging_syncup(view: SlidingSyncList) -> Self {
|
||||
let batch_size = view.batch_size;
|
||||
let limit = view.limit;
|
||||
let position = view
|
||||
@@ -581,10 +580,10 @@ impl SlidingSyncViewRequestGenerator {
|
||||
.map(|(_start, end)| u32::try_from(*end).unwrap())
|
||||
.unwrap_or_default();
|
||||
|
||||
SlidingSyncViewRequestGenerator {
|
||||
SlidingSyncListRequestGenerator {
|
||||
view,
|
||||
ranges: Default::default(),
|
||||
inner: InnerSlidingSyncViewRequestGenerator::PagingFullSync {
|
||||
inner: InnerSlidingSyncListRequestGenerator::PagingFullSync {
|
||||
position,
|
||||
batch_size,
|
||||
limit,
|
||||
@@ -593,7 +592,7 @@ impl SlidingSyncViewRequestGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
fn new_with_growing_syncup(view: SlidingSyncView) -> Self {
|
||||
fn new_with_growing_syncup(view: SlidingSyncList) -> Self {
|
||||
let batch_size = view.batch_size;
|
||||
let limit = view.limit;
|
||||
let position = view
|
||||
@@ -604,10 +603,10 @@ impl SlidingSyncViewRequestGenerator {
|
||||
.map(|(_start, end)| u32::try_from(*end).unwrap())
|
||||
.unwrap_or_default();
|
||||
|
||||
SlidingSyncViewRequestGenerator {
|
||||
SlidingSyncListRequestGenerator {
|
||||
view,
|
||||
ranges: Default::default(),
|
||||
inner: InnerSlidingSyncViewRequestGenerator::GrowingFullSync {
|
||||
inner: InnerSlidingSyncListRequestGenerator::GrowingFullSync {
|
||||
position,
|
||||
batch_size,
|
||||
limit,
|
||||
@@ -616,11 +615,11 @@ impl SlidingSyncViewRequestGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
fn new_live(view: SlidingSyncView) -> Self {
|
||||
SlidingSyncViewRequestGenerator {
|
||||
fn new_live(view: SlidingSyncList) -> Self {
|
||||
SlidingSyncListRequestGenerator {
|
||||
view,
|
||||
ranges: Default::default(),
|
||||
inner: InnerSlidingSyncViewRequestGenerator::Live,
|
||||
inner: InnerSlidingSyncListRequestGenerator::Live,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -702,10 +701,10 @@ impl SlidingSyncViewRequestGenerator {
|
||||
trace!(end, max_index, range_end, name = self.view.name, "updating state");
|
||||
|
||||
match &mut self.inner {
|
||||
InnerSlidingSyncViewRequestGenerator::PagingFullSync {
|
||||
InnerSlidingSyncListRequestGenerator::PagingFullSync {
|
||||
position, live, limit, ..
|
||||
}
|
||||
| InnerSlidingSyncViewRequestGenerator::GrowingFullSync {
|
||||
| InnerSlidingSyncListRequestGenerator::GrowingFullSync {
|
||||
position, live, limit, ..
|
||||
} => {
|
||||
let max = limit.map(|limit| std::cmp::min(limit, max_index)).unwrap_or(max_index);
|
||||
@@ -729,7 +728,7 @@ impl SlidingSyncViewRequestGenerator {
|
||||
});
|
||||
}
|
||||
}
|
||||
InnerSlidingSyncViewRequestGenerator::Live => {
|
||||
InnerSlidingSyncListRequestGenerator::Live => {
|
||||
Observable::update_eq(&mut self.view.state.write().unwrap(), |state| {
|
||||
*state = SlidingSyncState::Live;
|
||||
});
|
||||
@@ -738,30 +737,30 @@ impl SlidingSyncViewRequestGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterator for SlidingSyncViewRequestGenerator {
|
||||
impl Iterator for SlidingSyncListRequestGenerator {
|
||||
type Item = v4::SyncRequestList;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
match self.inner {
|
||||
InnerSlidingSyncViewRequestGenerator::PagingFullSync { live, .. }
|
||||
| InnerSlidingSyncViewRequestGenerator::GrowingFullSync { live, .. }
|
||||
InnerSlidingSyncListRequestGenerator::PagingFullSync { live, .. }
|
||||
| InnerSlidingSyncListRequestGenerator::GrowingFullSync { live, .. }
|
||||
if live =>
|
||||
{
|
||||
Some(self.live_request())
|
||||
}
|
||||
InnerSlidingSyncViewRequestGenerator::PagingFullSync {
|
||||
InnerSlidingSyncListRequestGenerator::PagingFullSync {
|
||||
position,
|
||||
batch_size,
|
||||
limit,
|
||||
..
|
||||
} => Some(self.prefetch_request(position, batch_size, limit)),
|
||||
InnerSlidingSyncViewRequestGenerator::GrowingFullSync {
|
||||
InnerSlidingSyncListRequestGenerator::GrowingFullSync {
|
||||
position,
|
||||
batch_size,
|
||||
limit,
|
||||
..
|
||||
} => Some(self.prefetch_request(0, position + batch_size, limit)),
|
||||
InnerSlidingSyncViewRequestGenerator::Live => Some(self.live_request()),
|
||||
InnerSlidingSyncListRequestGenerator::Live => Some(self.live_request()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -912,7 +911,7 @@ fn room_ops(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The state the [`SlidingSyncView`] is in.
|
||||
/// The state the [`SlidingSyncList`] is in.
|
||||
///
|
||||
/// The lifetime of a SlidingSync usually starts at a `Preload`, getting a fast
|
||||
/// response for the first given number of Rooms, then switches into
|
||||
@@ -934,7 +933,7 @@ pub enum SlidingSyncState {
|
||||
Live,
|
||||
}
|
||||
|
||||
/// The mode by which the the [`SlidingSyncView`] is in fetching the data.
|
||||
/// The mode by which the the [`SlidingSyncList`] is in fetching the data.
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum SlidingSyncMode {
|
||||
/// Fully sync all rooms in the background, page by page of `batch_size`,
|
||||
|
||||
@@ -85,10 +85,10 @@
|
||||
//! are **inclusive**) like so:
|
||||
//!
|
||||
//! ```rust
|
||||
//! # use matrix_sdk::sliding_sync::{SlidingSyncView, SlidingSyncMode};
|
||||
//! # use matrix_sdk::sliding_sync::{SlidingSyncList, SlidingSyncMode};
|
||||
//! use ruma::{assign, api::client::sync::sync_events::v4};
|
||||
//!
|
||||
//! let view_builder = SlidingSyncView::builder()
|
||||
//! let view_builder = SlidingSyncList::builder()
|
||||
//! .name("main_view")
|
||||
//! .sync_mode(SlidingSyncMode::Selective)
|
||||
//! .filters(Some(assign!(
|
||||
@@ -100,7 +100,7 @@
|
||||
//!
|
||||
//! Please refer to the [specification][MSC], the [Ruma types][ruma-types],
|
||||
//! specifically [`SyncRequestListFilter`](https://docs.rs/ruma/latest/ruma/api/client/sync/sync_events/v4/struct.SyncRequestListFilters.html) and the
|
||||
//! [`SlidingSyncViewBuilder`] for details on the filters, sort-order and
|
||||
//! [`SlidingSyncListBuilder`] for details on the filters, sort-order and
|
||||
//! range-options and data one requests to be sent. Once the view is fully
|
||||
//! configured, `build()` it and add the view to the sliding sync session
|
||||
//! by supplying it to [`add_view`][`SlidingSyncBuilder::add_view`].
|
||||
@@ -110,9 +110,9 @@
|
||||
//! copy can be retrieved by calling `SlidingSync::view()`, providing the name
|
||||
//! of the view. Next to the configuration settings (like name and
|
||||
//! `timeline_limit`), the view provides the stateful
|
||||
//! [`rooms_count`](SlidingSyncView::rooms_count),
|
||||
//! [`rooms_list`](SlidingSyncView::rooms_list) and
|
||||
//! [`state`](SlidingSyncView::state):
|
||||
//! [`rooms_count`](SlidingSyncList::rooms_count),
|
||||
//! [`rooms_list`](SlidingSyncList::rooms_list) and
|
||||
//! [`state`](SlidingSyncList::state):
|
||||
//!
|
||||
//! - `rooms_count` is the number of rooms _total_ there were found matching
|
||||
//! the filters given.
|
||||
@@ -143,8 +143,8 @@
|
||||
//! every request till all rooms or until `limit` of rooms are in view.
|
||||
//!
|
||||
//! For both, one should configure
|
||||
//! [`batch_size`](SlidingSyncViewBuilder::batch_size) and optionally
|
||||
//! [`limit`](SlidingSyncViewBuilder::limit) on the [`SlidingSyncViewBuilder`].
|
||||
//! [`batch_size`](SlidingSyncListBuilder::batch_size) and optionally
|
||||
//! [`limit`](SlidingSyncListBuilder::limit) on the [`SlidingSyncListBuilder`].
|
||||
//! Both full-sync views will notice if the number of rooms increased at runtime
|
||||
//! and will attempt to catch up to that (barring the `limit`).
|
||||
//!
|
||||
@@ -281,7 +281,7 @@
|
||||
//! # use futures::executor::block_on;
|
||||
//! # use futures::{pin_mut, StreamExt};
|
||||
//! # use matrix_sdk::{
|
||||
//! # sliding_sync::{SlidingSyncMode, SlidingSyncViewBuilder},
|
||||
//! # sliding_sync::{SlidingSyncMode, SlidingSyncListBuilder},
|
||||
//! # Client,
|
||||
//! # };
|
||||
//! # use ruma::{
|
||||
@@ -350,7 +350,7 @@
|
||||
//! # use futures::executor::block_on;
|
||||
//! # use futures::{pin_mut, StreamExt};
|
||||
//! # use matrix_sdk::{
|
||||
//! # sliding_sync::{SlidingSyncMode, SlidingSyncViewBuilder, SlidingSync, Error},
|
||||
//! # sliding_sync::{SlidingSyncMode, SlidingSyncListBuilder, SlidingSync, Error},
|
||||
//! # Client,
|
||||
//! # };
|
||||
//! # use ruma::{
|
||||
@@ -438,12 +438,12 @@
|
||||
//! present at `.build()`[`SlidingSyncBuilder::build`] sliding sync will attempt
|
||||
//! to load their latest cached version from storage, as well as some overall
|
||||
//! information of Sliding Sync. If that succeeded the views `state` has been
|
||||
//! set to [`Preload`][SlidingSyncViewState::Preload]. Only room data of rooms
|
||||
//! set to [`Preload`][SlidingSyncListState::Preload]. Only room data of rooms
|
||||
//! present in one of the views is loaded from storage.
|
||||
//!
|
||||
//! Once [#1441](https://github.com/matrix-org/matrix-rust-sdk/pull/1441) is merged
|
||||
//! one can disable caching on a per-view basis by setting
|
||||
//! [`cold_cache(false)`][`SlidingSyncViewBuilder::cold_cache`] when
|
||||
//! [`cold_cache(false)`][`SlidingSyncListBuilder::cold_cache`] when
|
||||
//! constructing the builder.
|
||||
//!
|
||||
//! Notice that views added after Sliding Sync has been built **will not be
|
||||
@@ -487,7 +487,7 @@
|
||||
//!
|
||||
//! ```no_run
|
||||
//! # use futures::executor::block_on;
|
||||
//! use matrix_sdk::{Client, sliding_sync::{SlidingSyncView, SlidingSyncMode}};
|
||||
//! use matrix_sdk::{Client, sliding_sync::{SlidingSyncList, SlidingSyncMode}};
|
||||
//! use ruma::{assign, {api::client::sync::sync_events::v4, events::StateEventType}};
|
||||
//! use tracing::{warn, error, info, debug};
|
||||
//! use futures::{StreamExt, pin_mut};
|
||||
@@ -504,7 +504,7 @@
|
||||
//! .with_common_extensions() // we want the e2ee and to-device enabled, please
|
||||
//! .cold_cache("example-cache".to_owned()); // we want these to be loaded from and stored into the persistent storage
|
||||
//!
|
||||
//! let full_sync_view = SlidingSyncView::builder()
|
||||
//! let full_sync_view = SlidingSyncList::builder()
|
||||
//! .sync_mode(SlidingSyncMode::GrowingFullSync) // sync up by growing the window
|
||||
//! .name(&full_sync_view_name) // needed to lookup again.
|
||||
//! .sort(vec!["by_recency".to_owned()]) // ordered by most recent
|
||||
@@ -515,7 +515,7 @@
|
||||
//! .limit(500) // only sync up the top 500 rooms
|
||||
//! .build()?;
|
||||
//!
|
||||
//! let active_view = SlidingSyncView::builder()
|
||||
//! let active_view = SlidingSyncList::builder()
|
||||
//! .name(&active_view_name) // the active window
|
||||
//! .sync_mode(SlidingSyncMode::Selective) // sync up the specific range only
|
||||
//! .set_range(0u32, 9u32) // only the top 10 items
|
||||
@@ -656,7 +656,7 @@ pub struct SlidingSync {
|
||||
delta_token: Arc<StdRwLock<Observable<Option<String>>>>,
|
||||
|
||||
/// The views of this sliding sync instance
|
||||
views: Arc<StdRwLock<BTreeMap<String, SlidingSyncView>>>,
|
||||
views: Arc<StdRwLock<BTreeMap<String, SlidingSyncList>>>,
|
||||
|
||||
/// The rooms details
|
||||
rooms: Arc<StdRwLock<BTreeMap<OwnedRoomId, SlidingSyncRoom>>>,
|
||||
@@ -714,7 +714,7 @@ impl SlidingSync {
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Write every `SlidingSyncView` inside the client the store.
|
||||
// Write every `SlidingSyncList` inside the client the store.
|
||||
let frozen_views = {
|
||||
let rooms_lock = self.rooms.read().unwrap();
|
||||
|
||||
@@ -725,7 +725,7 @@ impl SlidingSync {
|
||||
.map(|(name, view)| {
|
||||
Ok((
|
||||
format!("{storage_key}::{name}"),
|
||||
serde_json::to_vec(&FrozenSlidingSyncView::freeze(view, &rooms_lock))?,
|
||||
serde_json::to_vec(&FrozenSlidingSyncList::freeze(view, &rooms_lock))?,
|
||||
))
|
||||
})
|
||||
.collect::<Result<Vec<_>, crate::Error>>()?
|
||||
@@ -823,22 +823,22 @@ impl SlidingSync {
|
||||
.since = Some(since);
|
||||
}
|
||||
|
||||
/// Get access to the SlidingSyncView named `view_name`
|
||||
/// Get access to the SlidingSyncList named `view_name`
|
||||
///
|
||||
/// Note: Remember that this list might have been changed since you started
|
||||
/// listening to the stream and is therefor not necessarily up to date
|
||||
/// with the views used for the stream.
|
||||
pub fn view(&self, view_name: &str) -> Option<SlidingSyncView> {
|
||||
pub fn view(&self, view_name: &str) -> Option<SlidingSyncList> {
|
||||
self.views.read().unwrap().get(view_name).cloned()
|
||||
}
|
||||
|
||||
/// Remove the SlidingSyncView named `view_name` from the views list if
|
||||
/// Remove the SlidingSyncList named `view_name` from the views list if
|
||||
/// found
|
||||
///
|
||||
/// Note: Remember that this change will only be applicable for any new
|
||||
/// stream created after this. The old stream will still continue to use the
|
||||
/// previous set of views.
|
||||
pub fn pop_view(&self, view_name: &String) -> Option<SlidingSyncView> {
|
||||
pub fn pop_view(&self, view_name: &String) -> Option<SlidingSyncList> {
|
||||
self.views.write().unwrap().remove(view_name)
|
||||
}
|
||||
|
||||
@@ -851,7 +851,7 @@ impl SlidingSync {
|
||||
/// Note: Remember that this change will only be applicable for any new
|
||||
/// stream created after this. The old stream will still continue to use the
|
||||
/// previous set of views.
|
||||
pub fn add_view(&self, view: SlidingSyncView) -> Option<SlidingSyncView> {
|
||||
pub fn add_view(&self, view: SlidingSyncList) -> Option<SlidingSyncList> {
|
||||
self.views.write().unwrap().insert(view.name.clone(), view)
|
||||
}
|
||||
|
||||
@@ -876,7 +876,7 @@ impl SlidingSync {
|
||||
&self,
|
||||
sliding_sync_response: v4::Response,
|
||||
extensions: Option<ExtensionsConfig>,
|
||||
views: &mut BTreeMap<String, SlidingSyncViewRequestGenerator>,
|
||||
views: &mut BTreeMap<String, SlidingSyncListRequestGenerator>,
|
||||
) -> Result<UpdateSummary, crate::Error> {
|
||||
// Handle and transform a Sliding Sync Response to a `SyncResponse`.
|
||||
//
|
||||
@@ -966,7 +966,7 @@ impl SlidingSync {
|
||||
|
||||
async fn sync_once(
|
||||
&self,
|
||||
views: &mut BTreeMap<String, SlidingSyncViewRequestGenerator>,
|
||||
views: &mut BTreeMap<String, SlidingSyncListRequestGenerator>,
|
||||
) -> Result<Option<UpdateSummary>> {
|
||||
let mut lists_of_requests = BTreeMap::new();
|
||||
|
||||
@@ -1175,7 +1175,7 @@ mod test {
|
||||
#[tokio::test]
|
||||
async fn check_find_room_in_view() -> Result<()> {
|
||||
let view =
|
||||
SlidingSyncView::builder().name("testview").add_range(0u32, 9u32).build().unwrap();
|
||||
SlidingSyncList::builder().name("testview").add_range(0u32, 9u32).build().unwrap();
|
||||
let full_window_update: v4::SyncOp = serde_json::from_value(json! ({
|
||||
"op": "SYNC",
|
||||
"range": [0, 9],
|
||||
|
||||
@@ -7,7 +7,7 @@ pub mod state;
|
||||
|
||||
use matrix_sdk::{
|
||||
ruma::{api::client::error::ErrorKind, OwnedRoomId},
|
||||
Client, SlidingSyncState, SlidingSyncViewBuilder,
|
||||
Client, SlidingSyncState, SlidingSyncListBuilder,
|
||||
};
|
||||
|
||||
pub async fn run_client(
|
||||
@@ -17,7 +17,7 @@ pub async fn run_client(
|
||||
) -> Result<()> {
|
||||
info!("Starting sliding sync now");
|
||||
let builder = client.sliding_sync().await;
|
||||
let mut full_sync_view_builder = SlidingSyncViewBuilder::default_with_fullsync()
|
||||
let mut full_sync_view_builder = SlidingSyncListBuilder::default_with_fullsync()
|
||||
.timeline_limit(10u32)
|
||||
.sync_mode(config.full_sync_mode.into());
|
||||
if let Some(size) = config.batch_size {
|
||||
|
||||
@@ -9,7 +9,7 @@ use futures::{pin_mut, StreamExt};
|
||||
use matrix_sdk::{
|
||||
room::timeline::{Timeline, TimelineItem},
|
||||
ruma::{OwnedRoomId, RoomId},
|
||||
SlidingSync, SlidingSyncRoom, SlidingSyncState as ViewState, SlidingSyncView,
|
||||
SlidingSync, SlidingSyncRoom, SlidingSyncState as ViewState, SlidingSyncList,
|
||||
};
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
@@ -24,7 +24,7 @@ pub struct CurrentRoomSummary {
|
||||
pub struct SlidingSyncState {
|
||||
started: Instant,
|
||||
syncer: SlidingSync,
|
||||
view: SlidingSyncView,
|
||||
view: SlidingSyncList,
|
||||
/// the current list selector for the room
|
||||
first_render: Option<Duration>,
|
||||
full_sync: Option<Duration>,
|
||||
@@ -36,7 +36,7 @@ pub struct SlidingSyncState {
|
||||
}
|
||||
|
||||
impl SlidingSyncState {
|
||||
pub fn new(syncer: SlidingSync, view: SlidingSyncView) -> Self {
|
||||
pub fn new(syncer: SlidingSync, view: SlidingSyncList) -> Self {
|
||||
Self {
|
||||
started: Instant::now(),
|
||||
syncer,
|
||||
@@ -142,7 +142,7 @@ impl SlidingSyncState {
|
||||
self.first_render = Some(self.started.elapsed())
|
||||
}
|
||||
|
||||
pub fn view(&self) -> &SlidingSyncView {
|
||||
pub fn view(&self) -> &SlidingSyncList {
|
||||
&self.view
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ mod tests {
|
||||
api::client::error::ErrorKind as RumaError,
|
||||
events::room::message::RoomMessageEventContent, uint,
|
||||
},
|
||||
SlidingSyncMode, SlidingSyncState, SlidingSyncView,
|
||||
SlidingSyncMode, SlidingSyncState, SlidingSyncList,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
@@ -109,7 +109,7 @@ mod tests {
|
||||
let sync = sync_builder
|
||||
.clone()
|
||||
.add_view(
|
||||
SlidingSyncView::builder()
|
||||
SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::Selective)
|
||||
.add_range(0u32, 1)
|
||||
.timeline_limit(0u32)
|
||||
@@ -170,7 +170,7 @@ mod tests {
|
||||
let sync = sync_builder
|
||||
.clone()
|
||||
.add_view(
|
||||
SlidingSyncView::builder()
|
||||
SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::Selective)
|
||||
.name("visible_rooms_view")
|
||||
.add_range(0u32, 1)
|
||||
@@ -329,7 +329,7 @@ mod tests {
|
||||
|
||||
let (client, sync_proxy_builder) = random_setup_with_rooms(20).await?;
|
||||
let build_view = |name| {
|
||||
SlidingSyncView::builder()
|
||||
SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::Selective)
|
||||
.set_range(0u32, 10u32)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
@@ -415,7 +415,7 @@ mod tests {
|
||||
|
||||
let (client, sync_proxy_builder) = random_setup_with_rooms(20).await?;
|
||||
let build_view = |name| {
|
||||
SlidingSyncView::builder()
|
||||
SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::Selective)
|
||||
.set_range(0u32, 10u32)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
@@ -526,14 +526,14 @@ mod tests {
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn view_goes_live() -> anyhow::Result<()> {
|
||||
let (_client, sync_proxy_builder) = random_setup_with_rooms(21).await?;
|
||||
let sliding_window_view = SlidingSyncView::builder()
|
||||
let sliding_window_view = SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::Selective)
|
||||
.set_range(0u32, 10u32)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
.name("sliding")
|
||||
.build()?;
|
||||
|
||||
let full = SlidingSyncView::builder()
|
||||
let full = SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::GrowingFullSync)
|
||||
.batch_size(10u32)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
@@ -574,7 +574,7 @@ mod tests {
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn resizing_sliding_window() -> anyhow::Result<()> {
|
||||
let (_client, sync_proxy_builder) = random_setup_with_rooms(20).await?;
|
||||
let sliding_window_view = SlidingSyncView::builder()
|
||||
let sliding_window_view = SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::Selective)
|
||||
.set_range(0u32, 10u32)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
@@ -678,7 +678,7 @@ mod tests {
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn moving_out_of_sliding_window() -> anyhow::Result<()> {
|
||||
let (client, sync_proxy_builder) = random_setup_with_rooms(20).await?;
|
||||
let sliding_window_view = SlidingSyncView::builder()
|
||||
let sliding_window_view = SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::Selective)
|
||||
.set_range(1u32, 10u32)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
@@ -828,13 +828,13 @@ mod tests {
|
||||
let (_client, sync_proxy_builder) = random_setup_with_rooms(500).await?;
|
||||
print!("setup took its time");
|
||||
let build_views = || {
|
||||
let sliding_window_view = SlidingSyncView::builder()
|
||||
let sliding_window_view = SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::Selective)
|
||||
.set_range(1u32, 10u32)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
.name("sliding")
|
||||
.build()?;
|
||||
let growing_sync = SlidingSyncView::builder()
|
||||
let growing_sync = SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::GrowingFullSync)
|
||||
.limit(100)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
@@ -892,7 +892,7 @@ mod tests {
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn growing_sync_keeps_going() -> anyhow::Result<()> {
|
||||
let (_client, sync_proxy_builder) = random_setup_with_rooms(50).await?;
|
||||
let growing_sync = SlidingSyncView::builder()
|
||||
let growing_sync = SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::GrowingFullSync)
|
||||
.batch_size(10u32)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
@@ -944,7 +944,7 @@ mod tests {
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn growing_sync_keeps_going_after_restart() -> anyhow::Result<()> {
|
||||
let (_client, sync_proxy_builder) = random_setup_with_rooms(50).await?;
|
||||
let growing_sync = SlidingSyncView::builder()
|
||||
let growing_sync = SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::GrowingFullSync)
|
||||
.batch_size(10u32)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
@@ -1004,7 +1004,7 @@ mod tests {
|
||||
async fn continue_on_reset() -> anyhow::Result<()> {
|
||||
let (_client, sync_proxy_builder) = random_setup_with_rooms(30).await?;
|
||||
print!("setup took its time");
|
||||
let growing_sync = SlidingSyncView::builder()
|
||||
let growing_sync = SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::GrowingFullSync)
|
||||
.limit(100)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
@@ -1086,7 +1086,7 @@ mod tests {
|
||||
async fn noticing_new_rooms_in_growing() -> anyhow::Result<()> {
|
||||
let (client, sync_proxy_builder) = random_setup_with_rooms(30).await?;
|
||||
print!("setup took its time");
|
||||
let growing_sync = SlidingSyncView::builder()
|
||||
let growing_sync = SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::GrowingFullSync)
|
||||
.limit(100)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
@@ -1165,7 +1165,7 @@ mod tests {
|
||||
|
||||
let sync_proxy = sync_proxy_builder
|
||||
.add_view(
|
||||
SlidingSyncView::builder()
|
||||
SlidingSyncList::builder()
|
||||
.sync_mode(SlidingSyncMode::Selective)
|
||||
.set_range(0u32, 2u32)
|
||||
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
|
||||
|
||||
Reference in New Issue
Block a user