Browse Source

fix: group by field (#1374)

Nathan.fooo 2 years ago
parent
commit
c8044a92d1

+ 0 - 13
frontend/rust-lib/flowy-grid/src/entities/field_entities.rs

@@ -465,19 +465,6 @@ pub struct FieldChangesetParams {
 
     pub type_option_data: Option<Vec<u8>>,
 }
-
-impl FieldChangesetParams {
-    pub fn has_changes(&self) -> bool {
-        self.name.is_some()
-            || self.desc.is_some()
-            || self.field_type.is_some()
-            || self.frozen.is_some()
-            || self.type_option_data.is_some()
-            || self.frozen.is_some()
-            || self.visibility.is_some()
-            || self.width.is_some()
-    }
-}
 /// Certain field types have user-defined options such as color, date format, number format,
 /// or a list of values for a multi-select list. These options are defined within a specialization
 /// of the FieldTypeOption class.

+ 1 - 9
frontend/rust-lib/flowy-grid/src/services/grid_editor.rs

@@ -109,10 +109,6 @@ impl GridRevisionEditor {
         field_id: &str,
         type_option_data: Vec<u8>,
     ) -> FlowyResult<()> {
-        if type_option_data.is_empty() {
-            return Ok(());
-        }
-
         let result = self.get_field_rev(field_id).await;
         if result.is_none() {
             tracing::warn!("Can't find the field with id: {}", field_id);
@@ -307,10 +303,6 @@ impl GridRevisionEditor {
     #[tracing::instrument(level = "debug", skip_all, err)]
     async fn update_field_rev(&self, params: FieldChangesetParams, field_type: FieldType) -> FlowyResult<()> {
         let mut is_type_option_changed = false;
-        if !params.has_changes() {
-            return Ok(());
-        }
-
         let _ = self
             .modify(|grid| {
                 let changeset = grid.modify_field(&params.field_id, |field| {
@@ -334,11 +326,11 @@ impl GridRevisionEditor {
                     }
                     if let Some(type_option_data) = params.type_option_data {
                         let deserializer = TypeOptionJsonDeserializer(field_type);
+                        is_type_option_changed = true;
                         match deserializer.deserialize(type_option_data) {
                             Ok(json_str) => {
                                 let field_type = field.ty;
                                 field.insert_type_option_str(&field_type, json_str);
-                                is_type_option_changed = true;
                             }
                             Err(err) => {
                                 tracing::error!("Deserialize data to type option json failed: {}", err);