Browse Source

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

fix: update the group when the corresponding field changed
Nathan.fooo 2 years ago
parent
commit
f66b3a447c

+ 4 - 0
frontend/rust-lib/flowy-grid/src/services/grid_view_editor.rs

@@ -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);

+ 5 - 1
frontend/rust-lib/flowy-grid/src/services/grid_view_manager.rs

@@ -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(())
     }