diff --git a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs index 2b18a9efbb15..f06fb8fdbf2c 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database/database_editor.rs @@ -1981,12 +1981,11 @@ impl DatabaseViewOperation for DatabaseViewOperationImpl { } async fn get_cells_for_field(&self, view_id: &str, field_id: &str) -> Vec { - self - .database - .read() - .await - .get_cells_for_field(view_id, field_id) - .await + let editor = self.editor_by_view_id.read().await.get(view_id).cloned(); + match editor { + None => vec![], + Some(editor) => editor.v_get_cells_for_field(field_id).await, + } } async fn get_cell_in_row(&self, field_id: &str, row_id: &RowId) -> Arc { diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs index c95bd6d30bb8..9e018ab6e3cf 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database_view/view_editor.rs @@ -99,15 +99,7 @@ impl DatabaseViewEditor { .await; // Group - let group_controller = Arc::new(RwLock::new( - new_group_controller( - view_id.clone(), - delegate.clone(), - filter_controller.clone(), - None, - ) - .await?, - )); + let group_controller = Arc::new(RwLock::new(None)); // Calculations let calculations_controller = @@ -127,6 +119,20 @@ impl DatabaseViewEditor { }) } + pub async fn post_init(&self) -> FlowyResult<()> { + let group_controller = new_group_controller( + self.view_id.clone(), + self.delegate.clone(), + self.filter_controller.clone(), + None, + ) + .await?; + + *self.group_controller.write().await = group_controller; + + Ok(()) + } + pub async fn insert_row(&self, row: Option>, index: u32, row_order: &RowOrder) { let mut row_orders = self.row_orders.write().await; if row_orders.len() >= index as usize { diff --git a/frontend/rust-lib/flowy-database2/src/services/database_view/views.rs b/frontend/rust-lib/flowy-database2/src/services/database_view/views.rs index 278eb1f7d7e3..0aedfae42594 100644 --- a/frontend/rust-lib/flowy-database2/src/services/database_view/views.rs +++ b/frontend/rust-lib/flowy-database2/src/services/database_view/views.rs @@ -61,7 +61,6 @@ impl DatabaseViews { return Ok(editor.clone()); } - let mut editor_map = self.view_editors.write().await; let database_id = self.database.read().await.get_database_id(); let editor = Arc::new( DatabaseViewEditor::new( @@ -72,7 +71,9 @@ impl DatabaseViews { ) .await?, ); + let mut editor_map = self.view_editors.write().await; editor_map.insert(view_id.to_owned(), editor.clone()); + editor.post_init().await?; Ok(editor) }