Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
Feat/rename views (#2495)
Nathan.fooo2a35787dd13e
diff --git a/frontend/appflowy_flutter/lib/workspace/application/app/app_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/app/app_bloc.dartindex b1040360ee..ff2f15fe5b 100644--- a/frontend/appflowy_flutter/lib/workspace/application/app/app_bloc.dart+++ b/frontend/appflowy_flutter/lib/workspace/application/app/app_bloc.dart@@ -47,7 +47,7 @@ class AppBloc extends Bloc<AppEvent, AppState> {},appDidUpdate: (e) async {final latestCreatedView = state.latestCreatedView;- final views = e.app.belongings;+ final views = e.app.childViews;AppState newState = state.copyWith(views: views,view: e.app,@@ -174,7 +174,7 @@ class AppState with _$AppState {factory AppState.initial(ViewPB view) => AppState(view: view,- views: view.belongings,+ views: view.childViews,successOrFailure: left(unit),);}diff --git a/frontend/appflowy_flutter/lib/workspace/application/app/app_service.dart b/frontend/appflowy_flutter/lib/workspace/application/app/app_service.dartindex d0d6521761..8b2b9a12ff 100644--- a/frontend/appflowy_flutter/lib/workspace/application/app/app_service.dart+++ b/frontend/appflowy_flutter/lib/workspace/application/app/app_service.dart@@ -49,7 +49,7 @@ class AppBackendService {return FolderEventReadView(payload).send().then((result) {return result.fold(- (app) => left(app.belongings),+ (app) => left(app.childViews),(error) => right(error),);});@@ -130,7 +130,7 @@ class AppBackendService {return FolderEventReadView(payload).send().then((result) {return result.fold((app) => left(- app.belongings.firstWhere((e) => e.id == childViewID),+ app.childViews.firstWhere((e) => e.id == childViewID),),(error) => right(error),);diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/settings_file_exporter_cubit.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/settings_file_exporter_cubit.dartindex 5e75f744b5..62073d1561 100644--- a/frontend/appflowy_flutter/lib/workspace/application/settings/settings_file_exporter_cubit.dart+++ b/frontend/appflowy_flutter/lib/workspace/application/settings/settings_file_exporter_cubit.dart@@ -32,7 +32,7 @@ class SettingsFileExportState {expanded = views.map((e) => true).toList();selectedApps = views.map((e) => true).toList();selectedItems =- views.map((e) => e.belongings.map((e) => true).toList()).toList();+ views.map((e) => e.childViews.map((e) => true).toList()).toList();}}@@ -63,7 +63,7 @@ class SettingsFileExporterCubit extends Cubit<SettingsFileExportState> {final ids = <String>[];for (var j = 0; j < selectedItem.length; j++) {if (selectedItem[j]) {- ids.add(apps[i].belongings[j].id);+ ids.add(apps[i].childViews[j].id);}}if (ids.isNotEmpty) {diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/home_screen.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/home_screen.dartindex 48e9270c0a..79acfc2e36 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/home_screen.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/home_screen.dart@@ -275,7 +275,7 @@ class HomeScreenStackAdaptor extends HomeStackDelegate {homeService.readApp(appId: view.parentViewId).then((result) {result.fold((parentView) {- final List<ViewPB> views = parentView.belongings;+ final List<ViewPB> views = parentView.childViews;if (views.isNotEmpty) {var lastView = views.last;if (index != null && index != 0 && views.length > index - 1) {diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_exporter_widget.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_exporter_widget.dartindex 9d490d1b69..1dbd7a71ea 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_exporter_widget.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_file_exporter_widget.dart@@ -135,7 +135,7 @@ class _ExpandedListState extends State<_ExpandedList> {List<Widget> expandedChildren = [];if (isExpaned) {for (var i = 0; i < selectedItems[index].length; i++) {- final name = apps[index].belongings[i].name;+ final name = apps[index].childViews[i].name;final checkbox = CheckboxListTile(value: selectedItems[index][i],onChanged: (value) {diff --git a/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart b/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dartindex 476557a4ea..f4d109d21e 100644--- a/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart+++ b/frontend/appflowy_flutter/test/bloc_test/home_test/trash_bloc_test.dart@@ -43,7 +43,7 @@ class TrashTestContext {);await blocResponseFuture();- allViews = [...appBloc.state.view.belongings];+ allViews = [...appBloc.state.view.childViews];assert(allViews.length == 3, 'but receive ${allViews.length}');}}@@ -68,17 +68,17 @@ void main() {await blocResponseFuture(millisecond: 200);// delete a view- final deletedView = context.appBloc.state.view.belongings[0];+ final deletedView = context.appBloc.state.view.childViews[0];context.appBloc.add(AppEvent.deleteView(deletedView.id));await blocResponseFuture();- assert(context.appBloc.state.view.belongings.length == 2);+ assert(context.appBloc.state.view.childViews.length == 2);assert(trashBloc.state.objects.length == 1);assert(trashBloc.state.objects.first.id == deletedView.id);// put backtrashBloc.add(TrashEvent.putback(deletedView.id));await blocResponseFuture();- assert(context.appBloc.state.view.belongings.length == 3);+ assert(context.appBloc.state.view.childViews.length == 3);assert(trashBloc.state.objects.isEmpty);// delete all viewsdiff --git a/frontend/appflowy_tauri/src/appflowy_app/components/layout/Workspace.hooks.ts b/frontend/appflowy_tauri/src/appflowy_app/components/layout/Workspace.hooks.tsindex 39f98a5fd0..c6093cad12 100644--- a/frontend/appflowy_tauri/src/appflowy_app/components/layout/Workspace.hooks.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/components/layout/Workspace.hooks.ts@@ -23,7 +23,7 @@ export const useWorkspace = () => {for (const app of apps) {appDispatch(foldersActions.addFolder({ id: app.id, title: app.name }));- const views = app.belongings;+ const views = app.child_views;for (const view of views) {appDispatch(pagesActions.addPage({ folderId: app.id, id: view.id, pageType: view.layout, title: view.name }));}diff --git a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/folder/app/app_bd_svc.ts b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/folder/app/app_bd_svc.tsindex 57cabe7705..55b17a4721 100644--- a/frontend/appflowy_tauri/src/appflowy_app/stores/effects/folder/app/app_bd_svc.ts+++ b/frontend/appflowy_tauri/src/appflowy_app/stores/effects/folder/app/app_bd_svc.ts@@ -55,7 +55,7 @@ export class AppBackendService {getAllViews = (): Promise<Result<ViewPB[], FlowyError>> => {const payload = ViewIdPB.fromObject({ value: this.appId });return FolderEventReadView(payload).then((result) => {- return result.map((app) => app.belongings);+ return result.map((app) => app.child_views);});};diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_tests.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_tests.rsindex 319c87285d..19c41436d9 100644--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_tests.rs+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_tests.rs@@ -171,7 +171,7 @@ mod tests {date: Some("1653609600".to_owned()),time: Some("11:23 pm".to_owned()),include_time: Some(true),- timezone_id: Some("Etc/UTC".to_owned()),+ timezone_id: Some(chrono_tz::Tz::Etc__UTC.to_string()),},None,"May 27, 2022 11:23 PM",diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rsindex 448e276468..990551c97b 100644--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rs+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rs@@ -84,7 +84,7 @@ impl DateTypeOption {let naive = chrono::NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap();let offset = match Tz::from_str(&timezone_id) {Ok(timezone) => timezone.offset_from_utc_datetime(&naive).fix(),- Err(_) => Local::now().offset().clone(),+ Err(_) => *Local::now().offset(),};let date_time = DateTime::<Local>::from_utc(naive, offset);@@ -206,9 +206,8 @@ impl CellDataChangeset for DateTypeOption {.from_utc_datetime(&NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap()).date_naive(),),- None => match previous_datetime {- Some(datetime) => Some(timezone.from_utc_datetime(&datetime).date_naive()),- None => None,+ None => {+ previous_datetime.map(|datetime| timezone.from_utc_datetime(&datetime).date_naive())},};@@ -231,17 +230,15 @@ impl CellDataChangeset for DateTypeOption {Err(_) => match parsed_time {// same logic as above, but using local time instead of timezoneSome(time) => {- let offset = Local::now().offset().clone();-+ let offset = *Local::now().offset();let local_date = match new_date_timestamp {Some(timestamp) => Some(offset.from_utc_datetime(&NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap()).date_naive(),),- None => match previous_datetime {- Some(datetime) => Some(offset.from_utc_datetime(&datetime).date_naive()),- None => None,+ None => {+ previous_datetime.map(|datetime| offset.from_utc_datetime(&datetime).date_naive())},};diff --git a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rs b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rsindex c7b02bf329..026ac38dc2 100644--- a/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rs+++ b/frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option_entities.rs@@ -64,8 +64,7 @@ impl From<&Cell> for DateCellData {fn from(cell: &Cell) -> Self {let timestamp = cell.get_str_value(CELL_DATE)- .map(|data| data.parse::<i64>().ok())- .flatten();+ .and_then(|data| data.parse::<i64>().ok());let include_time = cell.get_bool_value("include_time").unwrap_or_default();let timezone_id = cell.get_str_value("timezone_id").unwrap_or_default();diff --git a/frontend/rust-lib/flowy-database2/tests/database/cell_test/script.rs b/frontend/rust-lib/flowy-database2/tests/database/cell_test/script.rsindex a8c5197fe2..9d2ad9937b 100644--- a/frontend/rust-lib/flowy-database2/tests/database/cell_test/script.rs+++ b/frontend/rust-lib/flowy-database2/tests/database/cell_test/script.rs@@ -46,7 +46,8 @@ impl DatabaseCellTest {&changeset.field_id,changeset.cell_changeset,)- .await;+ .await+ .unwrap();}, // CellScript::AssertGridRevisionPad => {// sleep(Duration::from_millis(2 * REVISION_WRITE_INTERVAL_IN_MILLIS)).await;// let mut grid_rev_manager = grid_manager.make_grid_rev_manager(&self.grid_id, pool.clone()).unwrap();diff --git a/frontend/rust-lib/flowy-database2/tests/database/database_editor.rs b/frontend/rust-lib/flowy-database2/tests/database/database_editor.rsindex 02f4ad853d..395b55e6bb 100644--- a/frontend/rust-lib/flowy-database2/tests/database/database_editor.rs+++ b/frontend/rust-lib/flowy-database2/tests/database/database_editor.rs@@ -12,6 +12,7 @@ use flowy_database2::services::field::{CheckboxTypeOption, ChecklistTypeOption, DateCellChangeset, MultiSelectTypeOption, SelectOption,SelectOptionCellChangeset, SingleSelectTypeOption,};+use flowy_error::FlowyResult;use flowy_test::helper::ViewTest;use flowy_test::FlowySDKTest;@@ -172,7 +173,7 @@ impl DatabaseEditorTest {field_id: &str,row_id: RowId,cell_changeset: T,- ) {+ ) -> FlowyResult<()> {let field = self.editor.get_fields(&self.view_id, None)@@ -183,10 +184,10 @@ impl DatabaseEditorTest {self.editor.update_cell_with_changeset(&self.view_id, row_id, &field.id, cell_changeset)- .await;+ .await}- pub(crate) async fn update_text_cell(&mut self, row_id: RowId, content: &str) {+ pub(crate) async fn update_text_cell(&mut self, row_id: RowId, content: &str) -> FlowyResult<()> {let field = self.editor.get_fields(&self.view_id, None)@@ -200,10 +201,14 @@ impl DatabaseEditorTest {self.update_cell(&field.id, row_id, content.to_string())- .await;+ .await}- pub(crate) async fn update_single_select_cell(&mut self, row_id: RowId, option_id: &str) {+ pub(crate) async fn update_single_select_cell(+ &mut self,+ row_id: RowId,+ option_id: &str,+ ) -> FlowyResult<()> {let field = self.editor.get_fields(&self.view_id, None)@@ -216,7 +221,7 @@ impl DatabaseEditorTest {.clone();let cell_changeset = SelectOptionCellChangeset::from_insert_option_id(option_id);- self.update_cell(&field.id, row_id, cell_changeset).await;+ self.update_cell(&field.id, row_id, cell_changeset).await}}@@ -253,12 +258,18 @@ impl TestRowBuilder {number_field.id.clone()}- pub fn insert_date_cell(&mut self, data: &str) -> String {+ pub fn insert_date_cell(+ &mut self,+ data: &str,+ time: Option<String>,+ include_time: Option<bool>,+ timezone_id: Option<String>,+ ) -> String {let value = serde_json::to_string(&DateCellChangeset {date: Some(data.to_string()),- time: None,- include_time: Some(false),- timezone_id: None,+ time,+ include_time,+ timezone_id,}).unwrap();let date_field = self.field_with_type(&FieldType::DateTime);diff --git a/frontend/rust-lib/flowy-database2/tests/database/filter_test/script.rs b/frontend/rust-lib/flowy-database2/tests/database/filter_test/script.rsindex e94b0bac36..93c3598dd4 100644--- a/frontend/rust-lib/flowy-database2/tests/database/filter_test/script.rs+++ b/frontend/rust-lib/flowy-database2/tests/database/filter_test/script.rs@@ -131,12 +131,12 @@ impl DatabaseFilterTest {FilterScript::UpdateTextCell { row_id, text, changed} => {self.recv = Some(self.editor.subscribe_view_changed(&self.view_id()).await.unwrap());self.assert_future_changed(changed).await;- self.update_text_cell(row_id, &text).await;+ self.update_text_cell(row_id, &text).await.unwrap();}FilterScript::UpdateSingleSelectCell { row_id, option_id, changed} => {self.recv = Some(self.editor.subscribe_view_changed(&self.view_id()).await.unwrap());self.assert_future_changed(changed).await;- self.update_single_select_cell(row_id, &option_id).await;+ self.update_single_select_cell(row_id, &option_id).await.unwrap();}FilterScript::InsertFilter { payload } => {self.recv = Some(self.editor.subscribe_view_changed(&self.view_id()).await.unwrap());diff --git a/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rs b/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rsindex 15b8bf83d5..60fcece858 100644--- a/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rs+++ b/frontend/rust-lib/flowy-database2/tests/database/group_test/script.rs@@ -183,7 +183,8 @@ impl DatabaseGroupTest {self.editor.update_cell(&self.view_id, row_id, &field_id, cell)- .await;+ .await+ .unwrap();},GroupScript::UpdateGroupedCellWithData {from_group_index,@@ -205,7 +206,8 @@ impl DatabaseGroupTest {self.editor.update_cell(&self.view_id, row_id, &field_id, cell)- .await;+ .await+ .unwrap();},GroupScript::MoveGroup {from_group_index,diff --git a/frontend/rust-lib/flowy-database2/tests/database/mock_data/board_mock_data.rs b/frontend/rust-lib/flowy-database2/tests/database/mock_data/board_mock_data.rsindex dee31caeff..a87de81b6f 100644--- a/frontend/rust-lib/flowy-database2/tests/database/mock_data/board_mock_data.rs+++ b/frontend/rust-lib/flowy-database2/tests/database/mock_data/board_mock_data.rs@@ -119,7 +119,12 @@ pub fn make_test_board() -> DatabaseData {FieldType::RichText => row_builder.insert_text_cell("A"),FieldType::Number => row_builder.insert_number_cell("1"),// 1647251762 => Mar 14,2022- FieldType::DateTime => row_builder.insert_date_cell("1647251762"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1647251762",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),FieldType::SingleSelect => {row_builder.insert_single_select_cell(|mut options| options.remove(0))},@@ -137,7 +142,12 @@ pub fn make_test_board() -> DatabaseData {FieldType::RichText => row_builder.insert_text_cell("B"),FieldType::Number => row_builder.insert_number_cell("2"),// 1647251762 => Mar 14,2022- FieldType::DateTime => row_builder.insert_date_cell("1647251762"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1647251762",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),FieldType::SingleSelect => {row_builder.insert_single_select_cell(|mut options| options.remove(0))},@@ -154,7 +164,12 @@ pub fn make_test_board() -> DatabaseData {FieldType::RichText => row_builder.insert_text_cell("C"),FieldType::Number => row_builder.insert_number_cell("3"),// 1647251762 => Mar 14,2022- FieldType::DateTime => row_builder.insert_date_cell("1647251762"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1647251762",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),FieldType::SingleSelect => {row_builder.insert_single_select_cell(|mut options| options.remove(1))},@@ -174,7 +189,12 @@ pub fn make_test_board() -> DatabaseData {match field_type {FieldType::RichText => row_builder.insert_text_cell("DA"),FieldType::Number => row_builder.insert_number_cell("4"),- FieldType::DateTime => row_builder.insert_date_cell("1668704685"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1668704685",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),FieldType::SingleSelect => {row_builder.insert_single_select_cell(|mut options| options.remove(1))},@@ -189,7 +209,12 @@ pub fn make_test_board() -> DatabaseData {match field_type {FieldType::RichText => row_builder.insert_text_cell("AE"),FieldType::Number => row_builder.insert_number_cell(""),- FieldType::DateTime => row_builder.insert_date_cell("1668359085"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1668359085",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),FieldType::SingleSelect => {row_builder.insert_single_select_cell(|mut options| options.remove(2))},diff --git a/frontend/rust-lib/flowy-database2/tests/database/mock_data/calendar_mock_data.rs b/frontend/rust-lib/flowy-database2/tests/database/mock_data/calendar_mock_data.rsindex 9761d232b5..a0d41734e8 100644--- a/frontend/rust-lib/flowy-database2/tests/database/mock_data/calendar_mock_data.rs+++ b/frontend/rust-lib/flowy-database2/tests/database/mock_data/calendar_mock_data.rs@@ -46,7 +46,12 @@ pub fn make_test_calendar() -> DatabaseData {for field_type in FieldType::iter() {match field_type {FieldType::RichText => row_builder.insert_text_cell("A"),- FieldType::DateTime => row_builder.insert_date_cell("1678090778"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1678090778",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),_ => "".to_owned(),};}@@ -55,7 +60,12 @@ pub fn make_test_calendar() -> DatabaseData {for field_type in FieldType::iter() {match field_type {FieldType::RichText => row_builder.insert_text_cell("B"),- FieldType::DateTime => row_builder.insert_date_cell("1677917978"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1677917978",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),_ => "".to_owned(),};}@@ -64,7 +74,12 @@ pub fn make_test_calendar() -> DatabaseData {for field_type in FieldType::iter() {match field_type {FieldType::RichText => row_builder.insert_text_cell("C"),- FieldType::DateTime => row_builder.insert_date_cell("1679213978"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1679213978",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),_ => "".to_owned(),};}@@ -73,7 +88,12 @@ pub fn make_test_calendar() -> DatabaseData {for field_type in FieldType::iter() {match field_type {FieldType::RichText => row_builder.insert_text_cell("D"),- FieldType::DateTime => row_builder.insert_date_cell("1678695578"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1678695578",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),_ => "".to_owned(),};}@@ -82,7 +102,12 @@ pub fn make_test_calendar() -> DatabaseData {for field_type in FieldType::iter() {match field_type {FieldType::RichText => row_builder.insert_text_cell("E"),- FieldType::DateTime => row_builder.insert_date_cell("1678695578"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1678695578",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),_ => "".to_owned(),};}diff --git a/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs b/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rsindex 83270d483c..fda266dea0 100644--- a/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs+++ b/frontend/rust-lib/flowy-database2/tests/database/mock_data/grid_mock_data.rs@@ -118,7 +118,12 @@ pub fn make_test_grid() -> DatabaseData {match field_type {FieldType::RichText => row_builder.insert_text_cell("A"),FieldType::Number => row_builder.insert_number_cell("1"),- FieldType::DateTime => row_builder.insert_date_cell("1647251762"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1647251762",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),FieldType::MultiSelect => row_builder.insert_multi_select_cell(|mut options| vec![options.remove(0), options.remove(0)]),FieldType::Checklist => row_builder.insert_checklist_cell(|options| options),@@ -135,7 +140,12 @@ pub fn make_test_grid() -> DatabaseData {match field_type {FieldType::RichText => row_builder.insert_text_cell(""),FieldType::Number => row_builder.insert_number_cell("2"),- FieldType::DateTime => row_builder.insert_date_cell("1647251762"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1647251762",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),FieldType::MultiSelect => row_builder.insert_multi_select_cell(|mut options| vec![options.remove(0), options.remove(1)]),FieldType::Checkbox => row_builder.insert_checkbox_cell("true"),@@ -148,7 +158,12 @@ pub fn make_test_grid() -> DatabaseData {match field_type {FieldType::RichText => row_builder.insert_text_cell("C"),FieldType::Number => row_builder.insert_number_cell("3"),- FieldType::DateTime => row_builder.insert_date_cell("1647251762"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1647251762",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),FieldType::SingleSelect => {row_builder.insert_single_select_cell(|mut options| options.remove(0))},@@ -165,7 +180,12 @@ pub fn make_test_grid() -> DatabaseData {match field_type {FieldType::RichText => row_builder.insert_text_cell("DA"),FieldType::Number => row_builder.insert_number_cell("4"),- FieldType::DateTime => row_builder.insert_date_cell("1668704685"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1668704685",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),FieldType::SingleSelect => {row_builder.insert_single_select_cell(|mut options| options.remove(0))},@@ -179,7 +199,12 @@ pub fn make_test_grid() -> DatabaseData {match field_type {FieldType::RichText => row_builder.insert_text_cell("AE"),FieldType::Number => row_builder.insert_number_cell(""),- FieldType::DateTime => row_builder.insert_date_cell("1668359085"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1668359085",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),FieldType::SingleSelect => {row_builder.insert_single_select_cell(|mut options| options.remove(1))},@@ -194,7 +219,12 @@ pub fn make_test_grid() -> DatabaseData {match field_type {FieldType::RichText => row_builder.insert_text_cell("AE"),FieldType::Number => row_builder.insert_number_cell("5"),- FieldType::DateTime => row_builder.insert_date_cell("1671938394"),+ FieldType::DateTime => row_builder.insert_date_cell(+ "1671938394",+ None,+ None,+ Some(chrono_tz::Tz::Etc__GMTPlus8.to_string()),+ ),FieldType::SingleSelect => {row_builder.insert_single_select_cell(|mut options| options.remove(1))},diff --git a/frontend/rust-lib/flowy-database2/tests/database/sort_test/script.rs b/frontend/rust-lib/flowy-database2/tests/database/sort_test/script.rsindex 102fa9fb13..7eedada1b4 100644--- a/frontend/rust-lib/flowy-database2/tests/database/sort_test/script.rs+++ b/frontend/rust-lib/flowy-database2/tests/database/sort_test/script.rs@@ -126,7 +126,7 @@ impl DatabaseSortTest {.await.unwrap(),);- self.update_text_cell(row_id, &text).await;+ self.update_text_cell(row_id, &text).await.unwrap();},SortScript::AssertSortChanged {new_row_orders,diff --git a/frontend/rust-lib/flowy-database2/tests/database/sort_test/single_sort_test.rs b/frontend/rust-lib/flowy-database2/tests/database/sort_test/single_sort_test.rsindex 3ca2705db9..dc6de08216 100644--- a/frontend/rust-lib/flowy-database2/tests/database/sort_test/single_sort_test.rs+++ b/frontend/rust-lib/flowy-database2/tests/database/sort_test/single_sort_test.rs@@ -184,7 +184,7 @@ async fn sort_date_by_descending_test() {"2022/03/14","2022/11/17","2022/11/13",- "2022/12/25",+ "2022/12/24",],},InsertSort {@@ -194,7 +194,7 @@ async fn sort_date_by_descending_test() {AssertCellContentOrder {field_id: date_field.id.clone(),orders: vec![- "2022/12/25",+ "2022/12/24","2022/11/17","2022/11/13","2022/03/14",diff --git a/frontend/rust-lib/flowy-folder2/src/entities/view.rs b/frontend/rust-lib/flowy-folder2/src/entities/view.rsindex e20827f7a1..1088686daf 100644--- a/frontend/rust-lib/flowy-folder2/src/entities/view.rs+++ b/frontend/rust-lib/flowy-folder2/src/entities/view.rs@@ -22,22 +22,35 @@ pub struct ViewPB {pub create_time: i64,#[pb(index = 5)]- pub belongings: Vec<ViewPB>,+ pub child_views: Vec<ViewPB>,#[pb(index = 6)]pub layout: ViewLayoutPB,}-impl std::convert::From<View> for ViewPB {- fn from(view: View) -> Self {- ViewPB {- id: view.id,- parent_view_id: view.bid,- name: view.name,- create_time: view.created_at,- belongings: Default::default(),- layout: view.layout.into(),- }+pub fn view_pb_without_child_views(view: View) -> ViewPB {+ ViewPB {+ id: view.id,+ parent_view_id: view.bid,+ name: view.name,+ create_time: view.created_at,+ child_views: Default::default(),+ layout: view.layout.into(),+ }+}++/// Returns a ViewPB with child views. Only the first level of child views are included.+pub fn view_pb_with_child_views(view: View, child_views: Vec<View>) -> ViewPB {+ ViewPB {+ id: view.id,+ parent_view_id: view.bid,+ name: view.name,+ create_time: view.created_at,+ child_views: child_views+ .into_iter()+ .map(view_pb_without_child_views)+ .collect(),+ layout: view.layout.into(),}}diff --git a/frontend/rust-lib/flowy-folder2/src/event_handler.rs b/frontend/rust-lib/flowy-folder2/src/event_handler.rsindex 17b9fb9ecc..f55fb9aa2e 100644--- a/frontend/rust-lib/flowy-folder2/src/event_handler.rs+++ b/frontend/rust-lib/flowy-folder2/src/event_handler.rs@@ -1,8 +1,9 @@use crate::entities::{- CreateViewParams, CreateViewPayloadPB, CreateWorkspaceParams, CreateWorkspacePayloadPB,- MoveFolderItemPayloadPB, MoveViewParams, RepeatedTrashIdPB, RepeatedTrashPB, RepeatedViewIdPB,- RepeatedViewPB, RepeatedWorkspacePB, TrashIdPB, UpdateViewParams, UpdateViewPayloadPB, ViewIdPB,- ViewPB, WorkspaceIdPB, WorkspacePB, WorkspaceSettingPB,+ view_pb_without_child_views, CreateViewParams, CreateViewPayloadPB, CreateWorkspaceParams,+ CreateWorkspacePayloadPB, MoveFolderItemPayloadPB, MoveViewParams, RepeatedTrashIdPB,+ RepeatedTrashPB, RepeatedViewIdPB, RepeatedViewPB, RepeatedWorkspacePB, TrashIdPB,+ UpdateViewParams, UpdateViewPayloadPB, ViewIdPB, ViewPB, WorkspaceIdPB, WorkspacePB,+ WorkspaceSettingPB,};use crate::manager::Folder2Manager;@@ -85,7 +86,7 @@ pub(crate) async fn create_view_handler(let params: CreateViewParams = data.into_inner().try_into()?;let view = folder.create_view_with_params(params).await?;let _ = folder.set_current_view(&view.id).await;- data_result_ok(view.into())+ data_result_ok(view_pb_without_child_views(view))}pub(crate) async fn read_view_handler(@@ -103,7 +104,7 @@ pub(crate) async fn update_view_handler(folder: AFPluginState<Arc<Folder2Manager>>,) -> Result<(), FlowyError> {let params: UpdateViewParams = data.into_inner().try_into()?;- let _ = folder.update_view_with_params(params).await?;+ folder.update_view_with_params(params).await?;Ok(())}diff --git a/frontend/rust-lib/flowy-folder2/src/manager.rs b/frontend/rust-lib/flowy-folder2/src/manager.rsindex 9c4f8a6ab4..c1436f9912 100644--- a/frontend/rust-lib/flowy-folder2/src/manager.rs+++ b/frontend/rust-lib/flowy-folder2/src/manager.rs@@ -16,8 +16,8 @@ use flowy_error::{FlowyError, FlowyResult};use lib_infra::util::timestamp;use crate::entities::{- CreateViewParams, CreateWorkspaceParams, RepeatedTrashPB, RepeatedViewPB, RepeatedWorkspacePB,- UpdateViewParams, ViewPB,+ view_pb_with_child_views, CreateViewParams, CreateWorkspaceParams, RepeatedTrashPB,+ RepeatedViewPB, RepeatedWorkspacePB, UpdateViewParams, ViewPB,};use crate::notification::{send_notification, send_workspace_notification, send_workspace_setting_notification,@@ -285,14 +285,13 @@ impl Folder2Manager {None => Err(FlowyError::record_not_found()),Some(mut view) => {view.belongings.retain(|b| !trash_ids.contains(&b.id));- let mut view_pb: ViewPB = view.into();- view_pb.belongings = folder+ let child_views = folder.views- .get_views_belong_to(&view_pb.id)+ .get_views_belong_to(&view.id).into_iter().filter(|view| !trash_ids.contains(&view.id))- .map(|view| view.into())- .collect::<Vec<ViewPB>>();+ .collect::<Vec<View>>();+ let view_pb = view_pb_with_child_views(view, child_views);Ok(view_pb)},}@@ -344,8 +343,8 @@ impl Folder2Manager {}#[tracing::instrument(level = "trace", skip(self), err)]- pub async fn update_view_with_params(&self, params: UpdateViewParams) -> FlowyResult<View> {- let view = self+ pub async fn update_view_with_params(&self, params: UpdateViewParams) -> FlowyResult<()> {+ let _ = self.folder.lock().as_ref()@@ -358,18 +357,13 @@ impl Folder2Manager {.done()});- match view {- None => Err(FlowyError::record_not_found()),- Some(view) => {- let view_pb: ViewPB = view.clone().into();- send_notification(&view.id, FolderNotification::DidUpdateView)- .payload(view_pb)- .send();-- notify_parent_view_did_change(self.folder.clone(), vec![view.bid.clone()]);- Ok(view)- },+ if let Ok(view_pb) = self.get_view(¶ms.view_id).await {+ send_notification(&view_pb.id, FolderNotification::DidUpdateView)+ .payload(view_pb)+ .send();}++ Ok(())}#[tracing::instrument(level = "debug", skip(self), err)]@@ -536,16 +530,13 @@ fn get_workspace_view_pbs(workspace_id: &str, folder: &InnerFolder) -> Vec<ViewPviews.into_iter().map(|view| {- let mut parent_view: ViewPB = view.into();-// Get child views- parent_view.belongings = folder+ let child_views = folder.views- .get_views_belong_to(&parent_view.id)+ .get_views_belong_to(&view.id).into_iter()- .map(|view| view.into()).collect();- parent_view+ view_pb_with_child_views(view, child_views)}).collect()}@@ -584,11 +575,7 @@ fn notify_parent_view_did_change<T: AsRef<str>>(event!(Level::DEBUG, child_views_count = child_views.len());// Post the notification- let mut parent_view_pb: ViewPB = parent_view.into();- parent_view_pb.belongings = child_views- .into_iter()- .map(|child_view| child_view.into())- .collect::<Vec<ViewPB>>();+ let parent_view_pb = view_pb_with_child_views(parent_view, child_views);send_notification(parent_view_id, FolderNotification::DidUpdateChildViews).payload(parent_view_pb).send();diff --git a/frontend/rust-lib/flowy-folder2/src/notification.rs b/frontend/rust-lib/flowy-folder2/src/notification.rsindex 5599b68d2f..0b9388e8cb 100644--- a/frontend/rust-lib/flowy-folder2/src/notification.rs+++ b/frontend/rust-lib/flowy-folder2/src/notification.rs@@ -1,4 +1,4 @@-use crate::entities::{ViewPB, WorkspacePB, WorkspaceSettingPB};+use crate::entities::{view_pb_without_child_views, WorkspacePB, WorkspaceSettingPB};use collab_folder::core::{View, Workspace};use flowy_derive::ProtoBuf_Enum;use flowy_notification::NotificationBuilder;@@ -62,7 +62,7 @@ pub(crate) fn send_workspace_setting_notification(current_view: Option<View>,) -> Option<()> {let workspace: WorkspacePB = current_workspace?.into();- let latest_view = current_view.map(ViewPB::from);+ let latest_view = current_view.map(view_pb_without_child_views);let setting = WorkspaceSettingPB {workspace,latest_view,diff --git a/frontend/rust-lib/flowy-folder2/src/user_default.rs b/frontend/rust-lib/flowy-folder2/src/user_default.rsindex 879a91ea32..fc30d93c98 100644--- a/frontend/rust-lib/flowy-folder2/src/user_default.rs+++ b/frontend/rust-lib/flowy-folder2/src/user_default.rs@@ -1,4 +1,4 @@-use crate::entities::{ViewPB, WorkspacePB};+use crate::entities::{view_pb_with_child_views, WorkspacePB};use crate::view_ext::{gen_view_id, ViewDataProcessorMap};use chrono::Utc;@@ -92,10 +92,7 @@ fn workspace_pb_from_workspace(view: &View,child_view: &View,) -> WorkspacePB {- let child_view_pb: ViewPB = child_view.clone().into();- let mut view_pb: ViewPB = view.clone().into();- view_pb.belongings.push(child_view_pb);-+ let view_pb = view_pb_with_child_views(view.clone(), vec![child_view.clone()]);WorkspacePB {id: workspace.id.clone(),name: workspace.name.clone(),diff --git a/frontend/rust-lib/flowy-folder2/tests/workspace/folder_test.rs b/frontend/rust-lib/flowy-folder2/tests/workspace/folder_test.rsindex 1171f34132..0bfd606f60 100644--- a/frontend/rust-lib/flowy-folder2/tests/workspace/folder_test.rs+++ b/frontend/rust-lib/flowy-folder2/tests/workspace/folder_test.rs@@ -149,9 +149,9 @@ async fn app_create_with_view() {.await;app = test.parent_view.clone();- assert_eq!(app.belongings.len(), 3);- assert_eq!(app.belongings[1].name, "View A");- assert_eq!(app.belongings[2].name, "Grid")+ assert_eq!(app.child_views.len(), 3);+ assert_eq!(app.child_views[1].name, "View A");+ assert_eq!(app.child_views[2].name, "Grid")}#[tokio::test]@@ -216,13 +216,13 @@ async fn view_delete_all() {.await;assert_eq!(- test.parent_view.belongings.len(),+ test.parent_view.child_views.len(),3,"num of belongings should be 3");let view_ids = test.parent_view- .belongings+ .child_views.iter().map(|view| view.id.clone()).collect::<Vec<String>>();@@ -234,7 +234,7 @@ async fn view_delete_all() {]).await;- assert_eq!(test.parent_view.belongings.len(), 0);+ assert_eq!(test.parent_view.child_views.len(), 0);assert_eq!(test.trash.len(), 3);}@@ -255,7 +255,7 @@ async fn view_delete_all_permanent() {let view_ids = test.parent_view- .belongings+ .child_views.iter().map(|view| view.id.clone()).collect::<Vec<String>>();@@ -268,6 +268,6 @@ async fn view_delete_all_permanent() {]).await;- assert_eq!(test.parent_view.belongings.len(), 0);+ assert_eq!(test.parent_view.child_views.len(), 0);assert_eq!(test.trash.len(), 0);}