Skip to content

Commit

Permalink
fix: quick and dirty hack job
Browse files Browse the repository at this point in the history
  • Loading branch information
richardshiue committed Nov 26, 2024
1 parent f337acd commit 2d9590a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1981,12 +1981,11 @@ impl DatabaseViewOperation for DatabaseViewOperationImpl {
}

async fn get_cells_for_field(&self, view_id: &str, field_id: &str) -> Vec<RowCell> {
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<RowCell> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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<Arc<Row>>, index: u32, row_order: &RowOrder) {
let mut row_orders = self.row_orders.write().await;
if row_orders.len() >= index as usize {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
}

Expand Down

0 comments on commit 2d9590a

Please sign in to comment.