Sfoglia il codice sorgente

fix: empty url group bug (#1755)

* fix: empty url group bug

moving a row to empty url (no status) group would change the row's
url to the group id which is not empty, its a random string.
fixed it with puting a check to fill the url with the empty string
when the group id is equal to empty url group id

* fix: move empty group check to `insert_url_cell`

because evereywhere using `insert_url_cell` we want to check that.

* chore: cargo fmt

---------

Co-authored-by: nathan <[email protected]>
Mohammad Zolfaghari 2 anni fa
parent
commit
59cb4a890a

+ 11 - 0
frontend/rust-lib/flowy-database/src/services/cell/cell_operation.rs

@@ -2,6 +2,7 @@ use crate::entities::FieldType;
 use crate::services::cell::{AtomicCellDataCache, CellProtobufBlob, TypeCellData};
 use crate::services::cell::{AtomicCellDataCache, CellProtobufBlob, TypeCellData};
 use crate::services::field::*;
 use crate::services::field::*;
 
 
+use crate::services::group::make_no_status_group;
 use flowy_error::{ErrorCode, FlowyError, FlowyResult};
 use flowy_error::{ErrorCode, FlowyError, FlowyResult};
 use grid_model::{CellRevision, FieldRevision};
 use grid_model::{CellRevision, FieldRevision};
 
 
@@ -223,6 +224,16 @@ pub fn insert_number_cell(num: i64, field_rev: &FieldRevision) -> CellRevision {
 }
 }
 
 
 pub fn insert_url_cell(url: String, field_rev: &FieldRevision) -> CellRevision {
 pub fn insert_url_cell(url: String, field_rev: &FieldRevision) -> CellRevision {
+  // checking if url is equal to group id of no status group because everywhere
+  // except group of rows with empty url the group id is equal to the url
+  // so then on the case that url is equal to empty url group id we should change
+  // the url to empty string
+  let _no_status_group_id = make_no_status_group(field_rev).id;
+  let url = match url {
+    a if a == _no_status_group_id => "".to_owned(),
+    _ => url,
+  };
+
   let data = apply_cell_data_changeset(url, None, field_rev, None).unwrap();
   let data = apply_cell_data_changeset(url, None, field_rev, None).unwrap();
   CellRevision::new(data)
   CellRevision::new(data)
 }
 }

+ 1 - 0
frontend/rust-lib/flowy-database/src/services/group/controller_impls/url_controller.rs

@@ -197,6 +197,7 @@ impl GroupGenerator for URLGroupGenerator {
     let group_configs = cells
     let group_configs = cells
       .into_iter()
       .into_iter()
       .flat_map(|value| value.into_url_field_cell_data())
       .flat_map(|value| value.into_url_field_cell_data())
+      .filter(|cell| !cell.content.is_empty())
       .map(|cell| GeneratedGroupConfig {
       .map(|cell| GeneratedGroupConfig {
         group_rev: make_group_from_url_cell(&cell),
         group_rev: make_group_from_url_cell(&cell),
         filter_content: cell.content,
         filter_content: cell.content,