mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Fix: flutter test (#2421)
* fix: tauri compile * ci: update * fix: flutter test
This commit is contained in:
@ -241,9 +241,6 @@ pub enum DatabaseEvent {
|
||||
#[event(input = "MoveGroupRowPayloadPB")]
|
||||
MoveGroupRow = 112,
|
||||
|
||||
#[event(input = "MoveGroupRowPayloadPB")]
|
||||
GroupByField = 113,
|
||||
|
||||
/// Returns all the databases
|
||||
#[event(output = "RepeatedDatabaseDescriptionPB")]
|
||||
GetDatabases = 114,
|
||||
|
@ -99,13 +99,15 @@ impl DatabaseEditor {
|
||||
}
|
||||
|
||||
pub async fn insert_group(&self, params: InsertGroupParams) -> FlowyResult<()> {
|
||||
if let Some(field) = self.database.lock().fields.get_field(¶ms.field_id) {
|
||||
let group_setting = default_group_setting(&field);
|
||||
self
|
||||
.database
|
||||
.lock()
|
||||
.insert_group_setting(¶ms.view_id, group_setting);
|
||||
{
|
||||
let database = self.database.lock();
|
||||
let field = database.fields.get_field(¶ms.field_id);
|
||||
if let Some(field) = field {
|
||||
let group_setting = default_group_setting(&field);
|
||||
database.insert_group_setting(¶ms.view_id, group_setting);
|
||||
}
|
||||
}
|
||||
|
||||
let view_editor = self.database_views.get_view_editor(¶ms.view_id).await?;
|
||||
view_editor.v_initialize_new_group(params).await?;
|
||||
Ok(())
|
||||
@ -122,6 +124,7 @@ impl DatabaseEditor {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "trace", skip_all, err)]
|
||||
pub async fn create_or_update_filter(&self, params: AlterFilterParams) -> FlowyResult<()> {
|
||||
let view_editor = self.database_views.get_view_editor(¶ms.view_id).await?;
|
||||
view_editor.v_insert_filter(params).await?;
|
||||
@ -198,7 +201,6 @@ impl DatabaseEditor {
|
||||
}
|
||||
|
||||
pub async fn delete_field(&self, field_id: &str) -> FlowyResult<()> {
|
||||
self.database.lock().delete_field(field_id);
|
||||
let database_id = {
|
||||
let database = self.database.lock();
|
||||
database.delete_field(field_id);
|
||||
@ -432,8 +434,13 @@ impl DatabaseEditor {
|
||||
}
|
||||
|
||||
pub async fn get_cell(&self, field_id: &str, row_id: RowId) -> CellPB {
|
||||
let field = self.database.lock().fields.get_field(field_id);
|
||||
let cell = self.database.lock().get_cell(field_id, &row_id);
|
||||
let (field, cell) = {
|
||||
let database = self.database.lock();
|
||||
let field = database.fields.get_field(field_id);
|
||||
let cell = database.get_cell(field_id, &row_id);
|
||||
(field, cell)
|
||||
};
|
||||
|
||||
match (field, cell) {
|
||||
(Some(field), Some(cell)) => {
|
||||
let field_type = FieldType::from(field.field_type);
|
||||
@ -483,10 +490,7 @@ impl DatabaseEditor {
|
||||
field_id: &str,
|
||||
new_cell: Cell,
|
||||
) -> Option<()> {
|
||||
let old_row = {
|
||||
let database = self.database.lock();
|
||||
database.get_row(&row_id)
|
||||
};
|
||||
let old_row = { self.database.lock().get_row(&row_id) };
|
||||
self.database.lock().update_row(&row_id, |row_update| {
|
||||
row_update.update_cells(|cell_update| {
|
||||
cell_update.insert(field_id, new_cell);
|
||||
|
@ -597,7 +597,7 @@ impl DatabaseViewEditor {
|
||||
pub async fn v_did_update_field_type_option(
|
||||
&self,
|
||||
field_id: &str,
|
||||
_old_field: &Field,
|
||||
old_field: &Field,
|
||||
) -> FlowyResult<()> {
|
||||
if let Some(field) = self.delegate.get_field(field_id).await {
|
||||
self
|
||||
@ -607,25 +607,25 @@ impl DatabaseViewEditor {
|
||||
.did_update_view_field_type_option(&field)
|
||||
.await;
|
||||
|
||||
// let filter = self
|
||||
// .delegate
|
||||
// .get_filter_by_field_id(&self.view_id, field_id);
|
||||
//
|
||||
// let old = old_field.map(|old_field| FilterType::from(filter));
|
||||
// let new = FilterType::from(field.as_ref());
|
||||
// let filter_type = UpdatedFilterType::new(old, new);
|
||||
// let filter_changeset = FilterChangeset::from_update(filter_type);
|
||||
// let filter_controller = self.filter_controller.clone();
|
||||
// let _ = tokio::spawn(async move {
|
||||
// if let Some(notification) = filter_controller
|
||||
// .did_receive_changes(filter_changeset)
|
||||
// .await
|
||||
// {
|
||||
// send_notification(¬ification.view_id, DatabaseNotification::DidUpdateFilter)
|
||||
// .payload(notification)
|
||||
// .send();
|
||||
// }
|
||||
// });
|
||||
if let Some(filter) = self
|
||||
.delegate
|
||||
.get_filter_by_field_id(&self.view_id, field_id)
|
||||
{
|
||||
let mut old = FilterType::from(&filter);
|
||||
old.field_type = FieldType::from(old_field.field_type);
|
||||
let new = FilterType::from(&filter);
|
||||
let filter_type = UpdatedFilterType::new(Some(old), new);
|
||||
let filter_changeset = FilterChangeset::from_update(filter_type);
|
||||
let filter_controller = self.filter_controller.clone();
|
||||
let _ = tokio::spawn(async move {
|
||||
if let Some(notification) = filter_controller
|
||||
.did_receive_changes(filter_changeset)
|
||||
.await
|
||||
{
|
||||
notify_did_update_filter(notification).await;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -131,6 +131,7 @@ impl std::convert::From<&FilterPB> for FilterType {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #[derive(Hash, Eq, PartialEq, Debug, Clone)]
|
||||
// pub struct InsertedFilterType {
|
||||
// pub field_id: String,
|
||||
|
@ -51,7 +51,7 @@ async fn grid_cell_update() {
|
||||
scripts.push(UpdateCell {
|
||||
changeset: CellChangesetPB {
|
||||
view_id: test.view_id.clone(),
|
||||
row_id: row.id.into(),
|
||||
row_id: row.id.clone().into(),
|
||||
field_id: field.id.clone(),
|
||||
cell_changeset,
|
||||
},
|
||||
|
@ -118,13 +118,13 @@ async fn grid_filter_single_select_is_test2() {
|
||||
},
|
||||
AssertNumberOfVisibleRows { expected: 2 },
|
||||
UpdateSingleSelectCell {
|
||||
row_id: rows[1].id,
|
||||
row_id: rows[1].id.clone(),
|
||||
option_id: option.id.clone(),
|
||||
changed: None,
|
||||
},
|
||||
AssertNumberOfVisibleRows { expected: 3 },
|
||||
UpdateSingleSelectCell {
|
||||
row_id: rows[1].id,
|
||||
row_id: rows[1].id.clone(),
|
||||
option_id: "".to_string(),
|
||||
changed: Some(FilterRowChanged {
|
||||
showing_num_of_rows: 0,
|
||||
|
@ -99,7 +99,7 @@ async fn grid_filter_contain_text_test2() {
|
||||
}),
|
||||
},
|
||||
UpdateTextCell {
|
||||
row_id: rows[1].id,
|
||||
row_id: rows[1].id.clone(),
|
||||
text: "ABC".to_string(),
|
||||
changed: Some(FilterRowChanged {
|
||||
showing_num_of_rows: 1,
|
||||
@ -232,7 +232,7 @@ async fn grid_filter_update_empty_text_cell_test() {
|
||||
},
|
||||
AssertFilterCount { count: 1 },
|
||||
UpdateTextCell {
|
||||
row_id: rows[0].id,
|
||||
row_id: rows[0].id.clone(),
|
||||
text: "".to_string(),
|
||||
changed: Some(FilterRowChanged {
|
||||
showing_num_of_rows: 1,
|
||||
|
@ -45,7 +45,7 @@ async fn sort_change_notification_by_update_text_test() {
|
||||
let rows = test.get_rows().await;
|
||||
let scripts = vec![
|
||||
UpdateTextCell {
|
||||
row_id: rows[2].id,
|
||||
row_id: rows[2].id.clone(),
|
||||
text: "E".to_string(),
|
||||
},
|
||||
AssertSortChanged {
|
||||
|
Reference in New Issue
Block a user