Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: row disappear when update the row in checkbox board (#1266)
Nathan.foooa516ec82bcfb
diff --git a/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option_entities.rs b/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option_entities.rsindex cfc123fad9..cfe6a7b65d 100644--- a/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option_entities.rs+++ b/frontend/rust-lib/flowy-grid/src/services/field/type_options/checkbox_type_option/checkbox_type_option_entities.rs@@ -12,6 +12,10 @@ impl CheckboxCellData {pub fn is_check(&self) -> bool {self.0 == CHECK}++ pub fn is_uncheck(&self) -> bool {+ self.0 == UNCHECK+ }}impl AsRef<[u8]> for CheckboxCellData {diff --git a/frontend/rust-lib/flowy-grid/src/services/group/controller.rs b/frontend/rust-lib/flowy-grid/src/services/group/controller.rsindex 397fcdd9eb..7826ce50c6 100644--- a/frontend/rust-lib/flowy-grid/src/services/group/controller.rs+++ b/frontend/rust-lib/flowy-grid/src/services/group/controller.rs@@ -270,12 +270,16 @@ wherelet cell_bytes = decode_any_cell_data(cell_rev.data.clone(), field_rev).1;let cell_data = cell_bytes.parser::<P>()?;let mut changesets = self.add_row_if_match(row_rev, &cell_data);- if let Some(default_group_changeset) = self.update_default_group(row_rev, &changesets) {- tracing::trace!("default_group_changeset: {}", default_group_changeset);- if !default_group_changeset.is_empty() {- changesets.push(default_group_changeset);++ if self.use_default_group() {+ if let Some(default_group_changeset) = self.update_default_group(row_rev, &changesets) {+ tracing::trace!("default_group_changeset: {}", default_group_changeset);+ if !default_group_changeset.is_empty() {+ changesets.push(default_group_changeset);+ }}}+Ok(changesets)} else {Ok(vec![])diff --git a/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/checkbox_controller.rs b/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/checkbox_controller.rsindex b26ff9bdbe..7d41ccefc0 100644--- a/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/checkbox_controller.rs+++ b/frontend/rust-lib/flowy-grid/src/services/group/controller_impls/checkbox_controller.rs@@ -43,17 +43,37 @@ impl GroupAction for CheckboxGroupController {let mut changesets = vec![];self.group_ctx.iter_mut_all_groups(|group| {let mut changeset = GroupChangesetPB::new(group.id.clone());- let is_contained = group.contains_row(&row_rev.id);- if group.id == CHECK && cell_data.is_check() {- if !is_contained {- let row_pb = RowPB::from(row_rev);- changeset.inserted_rows.push(InsertedRowPB::new(row_pb.clone()));- group.add_row(row_pb);+ let is_not_contained = !group.contains_row(&row_rev.id);+ if group.id == CHECK {+ if cell_data.is_uncheck() {+ // Remove the row if the group.id is CHECK but the cell_data is UNCHECK+ changeset.deleted_rows.push(row_rev.id.clone());+ group.remove_row(&row_rev.id);+ } else {+ // Add the row to the group if the group didn't contain the row+ if is_not_contained {+ let row_pb = RowPB::from(row_rev);+ changeset.inserted_rows.push(InsertedRowPB::new(row_pb.clone()));+ group.add_row(row_pb);+ }+ }+ }++ if group.id == UNCHECK {+ if cell_data.is_check() {+ // Remove the row if the group.id is UNCHECK but the cell_data is CHECK+ changeset.deleted_rows.push(row_rev.id.clone());+ group.remove_row(&row_rev.id);+ } else {+ // Add the row to the group if the group didn't contain the row+ if is_not_contained {+ let row_pb = RowPB::from(row_rev);+ changeset.inserted_rows.push(InsertedRowPB::new(row_pb.clone()));+ group.add_row(row_pb);+ }}- } else if is_contained {- changeset.deleted_rows.push(row_rev.id.clone());- group.remove_row(&row_rev.id);}+if !changeset.is_empty() {changesets.push(changeset);}