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 <nathan@appflowy.io>
This commit is contained in:
Mohammad Zolfaghari 2023-02-13 14:25:03 +03:30 committed by GitHub
parent 91b942d319
commit 59cb4a890a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,7 @@ use crate::entities::FieldType;
use crate::services::cell::{AtomicCellDataCache, CellProtobufBlob, TypeCellData};
use crate::services::field::*;
use crate::services::group::make_no_status_group;
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
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 {
// 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();
CellRevision::new(data)
}

View File

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