Merge pull request #1176 from AppFlowy-IO/fix/update_group_if_field_changed

fix: update the group when the corresponding field changed
This commit is contained in:
Nathan.fooo 2022-09-27 13:53:49 +08:00 committed by GitHub
commit f66b3a447c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -201,6 +201,10 @@ impl GridViewRevisionEditor {
Ok(())
}
pub(crate) async fn group_id(&self) -> String {
self.group_controller.read().await.field_id().to_owned()
}
pub(crate) async fn get_setting(&self) -> GridSettingPB {
let field_revs = self.field_delegate.get_field_revs().await;
let grid_setting = make_grid_setting(&*self.pad.read().await, &field_revs);

View File

@ -178,12 +178,16 @@ impl GridViewManager {
#[tracing::instrument(level = "trace", skip(self), err)]
pub(crate) async fn did_update_field(&self, field_id: &str, is_type_option_changed: bool) -> FlowyResult<()> {
let view_editor = self.get_default_view_editor().await?;
// Only the field_id of the updated field is equal to the field_id of the group.
// Update the group
if view_editor.group_id().await != field_id {
return Ok(());
}
if is_type_option_changed {
let _ = view_editor.group_by_field(field_id).await?;
} else {
let _ = view_editor.did_update_field(field_id).await?;
}
Ok(())
}