mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-16 03:55:42 -04:00
chore(ui): Rename State::FirstRooms and State::AllRooms.
This patch renames `State::FirstRooms` to `State::SettingUp`, and `State::Running` as requested by users. It hides the “inner Sliding Sync logic”, the Sliding Sync lists etc.
This commit is contained in:
@@ -21,11 +21,12 @@ pub enum State {
|
||||
/// That's the first initial state.
|
||||
Init,
|
||||
|
||||
/// At this state, the first rooms start to be synced.
|
||||
FirstRooms,
|
||||
/// At this state, the first rooms are starting to sync.
|
||||
SettingUp,
|
||||
|
||||
/// At this state, all rooms start to be synced.
|
||||
AllRooms,
|
||||
/// At this state, all rooms are syncing, and the visible rooms + invites
|
||||
/// lists exist.
|
||||
Running,
|
||||
|
||||
/// This state is the cruising speed, i.e. the “normal” state, where nothing
|
||||
/// fancy happens: all rooms are syncing, and life is great.
|
||||
@@ -43,9 +44,9 @@ impl State {
|
||||
use State::*;
|
||||
|
||||
let (next_state, actions) = match self {
|
||||
Init => (FirstRooms, Actions::none()),
|
||||
FirstRooms => (AllRooms, Actions::first_rooms_are_loaded()),
|
||||
AllRooms => (CarryOn, Actions::none()),
|
||||
Init => (SettingUp, Actions::none()),
|
||||
SettingUp => (Running, Actions::first_rooms_are_loaded()),
|
||||
Running => (CarryOn, Actions::none()),
|
||||
CarryOn => (CarryOn, Actions::none()),
|
||||
// If the state was `Terminated`, the next state is calculated again, because it means
|
||||
// the sync has been restarted. In this case, let's jump back on the
|
||||
@@ -53,12 +54,12 @@ impl State {
|
||||
// scenario.
|
||||
Terminated { from: previous_state } => {
|
||||
match previous_state.as_ref() {
|
||||
state @ Init | state @ FirstRooms => {
|
||||
state @ Init | state @ SettingUp => {
|
||||
// Do nothing.
|
||||
(state.to_owned(), Actions::none())
|
||||
}
|
||||
|
||||
state @ AllRooms | state @ CarryOn => {
|
||||
state @ Running | state @ CarryOn => {
|
||||
// Refresh the lists.
|
||||
(state.to_owned(), Actions::refresh_lists())
|
||||
}
|
||||
@@ -233,24 +234,24 @@ mod tests {
|
||||
|
||||
// Next state.
|
||||
let state = state.next(sliding_sync).await?;
|
||||
assert_eq!(state, State::FirstRooms);
|
||||
assert_eq!(state, State::SettingUp);
|
||||
|
||||
// Hypothetical termination.
|
||||
{
|
||||
let state =
|
||||
State::Terminated { from: Box::new(state.clone()) }.next(sliding_sync).await?;
|
||||
assert_eq!(state, State::FirstRooms);
|
||||
assert_eq!(state, State::SettingUp);
|
||||
}
|
||||
|
||||
// Next state.
|
||||
let state = state.next(sliding_sync).await?;
|
||||
assert_eq!(state, State::AllRooms);
|
||||
assert_eq!(state, State::Running);
|
||||
|
||||
// Hypothetical termination.
|
||||
{
|
||||
let state =
|
||||
State::Terminated { from: Box::new(state.clone()) }.next(sliding_sync).await?;
|
||||
assert_eq!(state, State::AllRooms);
|
||||
assert_eq!(state, State::Running);
|
||||
}
|
||||
|
||||
// Next state.
|
||||
|
||||
@@ -201,7 +201,7 @@ macro_rules! assert_entries_stream {
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
async fn test_sync_from_init_to_enjoy() -> Result<(), Error> {
|
||||
async fn test_sync_all_states() -> Result<(), Error> {
|
||||
let (server, room_list) = new_room_list().await?;
|
||||
|
||||
let (entries_loading_state, mut entries_loading_state_stream) =
|
||||
@@ -214,7 +214,7 @@ async fn test_sync_from_init_to_enjoy() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = Init => FirstRooms,
|
||||
states = Init => SettingUp,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -277,7 +277,7 @@ async fn test_sync_from_init_to_enjoy() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = FirstRooms => AllRooms,
|
||||
states = SettingUp => Running,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -349,7 +349,7 @@ async fn test_sync_from_init_to_enjoy() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = AllRooms => CarryOn,
|
||||
states = Running => CarryOn,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -491,7 +491,7 @@ async fn test_sync_resumes_from_previous_state() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = Init => FirstRooms,
|
||||
states = Init => SettingUp,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -519,7 +519,7 @@ async fn test_sync_resumes_from_previous_state() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = FirstRooms => AllRooms,
|
||||
states = SettingUp => Running,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -561,7 +561,7 @@ async fn test_sync_resumes_from_previous_state() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = AllRooms => CarryOn,
|
||||
states = Running => CarryOn,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -635,7 +635,7 @@ async fn test_sync_resumes_from_terminated() -> Result<(), Error> {
|
||||
// Do a regular sync from the `Terminated` state.
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = Terminated { .. } => FirstRooms,
|
||||
states = Terminated { .. } => SettingUp,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -655,15 +655,15 @@ async fn test_sync_resumes_from_terminated() -> Result<(), Error> {
|
||||
},
|
||||
};
|
||||
|
||||
// Simulate an error from the `FirstRooms` state.
|
||||
// Simulate an error from the `SettingUp` state.
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
sync matches Some(Err(_)),
|
||||
states = FirstRooms => Terminated { .. },
|
||||
states = SettingUp => Terminated { .. },
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
// In `FirstRooms`, the sync-mode has changed to growing, with
|
||||
// In `SettingUp`, the sync-mode has changed to growing, with
|
||||
// its initial range.
|
||||
"ranges": [[0, 49]],
|
||||
},
|
||||
@@ -696,11 +696,11 @@ async fn test_sync_resumes_from_terminated() -> Result<(), Error> {
|
||||
// Do a regular sync from the `Terminated` state.
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = Terminated { .. } => AllRooms,
|
||||
states = Terminated { .. } => Running,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
// In `AllRooms`, the sync-mode is still growing, but the range
|
||||
// In `Running`, the sync-mode is still growing, but the range
|
||||
// hasn't been modified due to previous error.
|
||||
"ranges": [[0, 49]],
|
||||
},
|
||||
@@ -728,15 +728,15 @@ async fn test_sync_resumes_from_terminated() -> Result<(), Error> {
|
||||
},
|
||||
};
|
||||
|
||||
// Simulate an error from the `AllRooms` state.
|
||||
// Simulate an error from the `Running` state.
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
sync matches Some(Err(_)),
|
||||
states = AllRooms => Terminated { .. },
|
||||
states = Running => Terminated { .. },
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
// In `AllRooms`, the sync-mode is still growing, and the range
|
||||
// In `Running`, the sync-mode is still growing, and the range
|
||||
// has made progress.
|
||||
"ranges": [[0, 99]],
|
||||
},
|
||||
@@ -914,7 +914,7 @@ async fn test_sync_can_be_stopped() -> Result<(), Error> {
|
||||
// First sync, everything is alright and up and running.
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = Init => FirstRooms,
|
||||
states = Init => SettingUp,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -946,7 +946,7 @@ async fn test_sync_can_be_stopped() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = Terminated { .. } => AllRooms,
|
||||
states = Terminated { .. } => Running,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -992,7 +992,7 @@ async fn test_entries_stream() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = Init => FirstRooms,
|
||||
states = Init => SettingUp,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -1050,7 +1050,7 @@ async fn test_entries_stream() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = FirstRooms => AllRooms,
|
||||
states = SettingUp => Running,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -1125,7 +1125,7 @@ async fn test_entries_stream_with_updated_filter() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = Init => FirstRooms,
|
||||
states = Init => SettingUp,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -1179,7 +1179,7 @@ async fn test_entries_stream_with_updated_filter() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = FirstRooms => AllRooms,
|
||||
states = SettingUp => Running,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -1266,7 +1266,7 @@ async fn test_invites_stream() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = Init => FirstRooms,
|
||||
states = Init => SettingUp,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -1292,7 +1292,7 @@ async fn test_invites_stream() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = FirstRooms => AllRooms,
|
||||
states = SettingUp => Running,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -1352,7 +1352,7 @@ async fn test_invites_stream() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = AllRooms => CarryOn,
|
||||
states = Running => CarryOn,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -1908,7 +1908,7 @@ async fn test_input_viewport() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = Init => FirstRooms,
|
||||
states = Init => SettingUp,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -1925,7 +1925,7 @@ async fn test_input_viewport() -> Result<(), Error> {
|
||||
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = FirstRooms => AllRooms,
|
||||
states = SettingUp => Running,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
@@ -1952,7 +1952,7 @@ async fn test_input_viewport() -> Result<(), Error> {
|
||||
// The `timeline_limit` is not repeated because it's sticky.
|
||||
sync_then_assert_request_and_fake_response! {
|
||||
[server, room_list, sync]
|
||||
states = AllRooms => CarryOn,
|
||||
states = Running => CarryOn,
|
||||
assert request >= {
|
||||
"lists": {
|
||||
ALL_ROOMS: {
|
||||
|
||||
Reference in New Issue
Block a user