mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: migrate cloud document when the document content is not sync to … (#4108)
* fix: migrate cloud document when the document content is not sync to local * chore: clippy
This commit is contained in:
@ -220,7 +220,7 @@ impl TryInto<CreateFieldParams> for CreateFieldPayloadPB {
|
||||
CreateFieldPosition::Before => {
|
||||
let field_id = self
|
||||
.target_field_id
|
||||
.ok_or_else(|| ErrorCode::InvalidParams)?;
|
||||
.ok_or(ErrorCode::InvalidParams)?;
|
||||
let field_id = NotEmptyStr::parse(field_id)
|
||||
.map_err(|_| ErrorCode::InvalidParams)?
|
||||
.0;
|
||||
@ -229,7 +229,7 @@ impl TryInto<CreateFieldParams> for CreateFieldPayloadPB {
|
||||
CreateFieldPosition::After => {
|
||||
let field_id = self
|
||||
.target_field_id
|
||||
.ok_or_else(|| ErrorCode::InvalidParams)?;
|
||||
.ok_or(ErrorCode::InvalidParams)?;
|
||||
let field_id = NotEmptyStr::parse(field_id)
|
||||
.map_err(|_| ErrorCode::InvalidParams)?
|
||||
.0;
|
||||
@ -564,7 +564,7 @@ pub enum FieldType {
|
||||
|
||||
impl Display for FieldType {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let value: i64 = self.clone().into();
|
||||
let value: i64 = (*self).into();
|
||||
f.write_fmt(format_args!("{}", value))
|
||||
}
|
||||
}
|
||||
@ -577,13 +577,13 @@ impl AsRef<FieldType> for FieldType {
|
||||
|
||||
impl From<&FieldType> for FieldType {
|
||||
fn from(field_type: &FieldType) -> Self {
|
||||
field_type.clone()
|
||||
*field_type
|
||||
}
|
||||
}
|
||||
|
||||
impl FieldType {
|
||||
pub fn value(&self) -> i64 {
|
||||
self.clone().into()
|
||||
(*self).into()
|
||||
}
|
||||
|
||||
pub fn default_name(&self) -> String {
|
||||
@ -666,7 +666,7 @@ impl From<FieldType> for i64 {
|
||||
|
||||
impl From<&FieldType> for i64 {
|
||||
fn from(ty: &FieldType) -> Self {
|
||||
i64::from(ty.clone())
|
||||
i64::from(*ty)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ impl std::convert::From<&Filter> for FilterPB {
|
||||
Self {
|
||||
id: filter.id.clone(),
|
||||
field_id: filter.field_id.clone(),
|
||||
field_type: filter.field_type.clone(),
|
||||
field_type: filter.field_type,
|
||||
data: bytes.to_vec(),
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ impl std::convert::From<&Sort> for SortPB {
|
||||
Self {
|
||||
id: sort.id.clone(),
|
||||
field_id: sort.field_id.clone(),
|
||||
field_type: sort.field_type.clone(),
|
||||
field_type: sort.field_type,
|
||||
condition: sort.condition.into(),
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ impl TypeCellData {
|
||||
pub fn from_field_type(field_type: &FieldType) -> TypeCellData {
|
||||
Self {
|
||||
cell_str: "".to_string(),
|
||||
field_type: field_type.clone(),
|
||||
field_type: *field_type,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ impl DatabaseEditor {
|
||||
}
|
||||
|
||||
let old_field_type = FieldType::from(field.field_type);
|
||||
let old_type_option = field.get_any_type_option(old_field_type.clone());
|
||||
let old_type_option = field.get_any_type_option(old_field_type);
|
||||
let new_type_option = field
|
||||
.get_any_type_option(new_field_type)
|
||||
.unwrap_or_else(|| default_type_option_data_from_type(new_field_type));
|
||||
@ -464,7 +464,7 @@ impl DatabaseEditor {
|
||||
field.map(|field| {
|
||||
let field_type = FieldType::from(field.field_type);
|
||||
let type_option = field
|
||||
.get_any_type_option(field_type.clone())
|
||||
.get_any_type_option(field_type)
|
||||
.unwrap_or_else(|| default_type_option_data_from_type(&field_type));
|
||||
(field, type_option_to_pb(type_option, &field_type))
|
||||
})
|
||||
@ -1265,7 +1265,7 @@ impl DatabaseViewOperation for DatabaseViewOperationImpl {
|
||||
let (_, field) = self.database.lock().create_field_with_mut(
|
||||
view_id,
|
||||
name.to_string(),
|
||||
field_type.clone().into(),
|
||||
field_type.into(),
|
||||
&OrderObjectPosition::default(),
|
||||
|field| {
|
||||
field
|
||||
|
@ -139,7 +139,7 @@ impl DatabaseLayoutDepsResolver {
|
||||
Field::new(
|
||||
field_id,
|
||||
"Date".to_string(),
|
||||
field_type.clone().into(),
|
||||
field_type.into(),
|
||||
false,
|
||||
)
|
||||
.with_type_option_data(field_type, default_date_type_option.into())
|
||||
@ -152,7 +152,7 @@ impl DatabaseLayoutDepsResolver {
|
||||
Field::new(
|
||||
field_id,
|
||||
"Status".to_string(),
|
||||
field_type.clone().into(),
|
||||
field_type.into(),
|
||||
false,
|
||||
)
|
||||
.with_type_option_data(field_type, default_select_type_option.into())
|
||||
|
@ -118,7 +118,7 @@ pub(crate) async fn get_cell_for_row(
|
||||
Some(RowSingleCellData {
|
||||
row_id: row_cell.row_id.clone(),
|
||||
field_id: field.id.clone(),
|
||||
field_type: field_type.clone(),
|
||||
field_type,
|
||||
cell_data,
|
||||
})
|
||||
}
|
||||
@ -143,7 +143,7 @@ pub(crate) async fn get_cells_for_field(
|
||||
RowSingleCellData {
|
||||
row_id: row_cell.row_id.clone(),
|
||||
field_id: field.id.clone(),
|
||||
field_type: field_type.clone(),
|
||||
field_type,
|
||||
cell_data,
|
||||
}
|
||||
})
|
||||
|
@ -12,7 +12,7 @@ impl FieldBuilder {
|
||||
let mut field = Field::new(
|
||||
gen_field_id(),
|
||||
"".to_string(),
|
||||
field_type.clone().into(),
|
||||
field_type.into(),
|
||||
false,
|
||||
);
|
||||
field.width = 150;
|
||||
|
@ -12,7 +12,7 @@ mod tests {
|
||||
fn checkout_box_description_test() {
|
||||
let type_option = CheckboxTypeOption::default();
|
||||
let field_type = FieldType::Checkbox;
|
||||
let field_rev = FieldBuilder::from_field_type(field_type.clone()).build();
|
||||
let field_rev = FieldBuilder::from_field_type(field_type).build();
|
||||
|
||||
// the checkout value will be checked if the value is "1", "true" or "yes"
|
||||
assert_checkbox(&type_option, "1", CHECK, &field_type, &field_rev);
|
||||
|
@ -12,7 +12,7 @@ mod tests {
|
||||
fn number_type_option_input_test() {
|
||||
let type_option = NumberTypeOption::default();
|
||||
let field_type = FieldType::Number;
|
||||
let field = FieldBuilder::from_field_type(field_type.clone()).build();
|
||||
let field = FieldBuilder::from_field_type(field_type).build();
|
||||
|
||||
// Input is empty String
|
||||
assert_number(&type_option, "", "", &field_type, &field);
|
||||
@ -31,7 +31,7 @@ mod tests {
|
||||
let field_type = FieldType::Number;
|
||||
let mut type_option = NumberTypeOption::new();
|
||||
type_option.format = NumberFormat::USD;
|
||||
let field = FieldBuilder::new(field_type.clone(), type_option.clone()).build();
|
||||
let field = FieldBuilder::new(field_type, type_option.clone()).build();
|
||||
|
||||
assert_number(&type_option, "", "", &field_type, &field);
|
||||
assert_number(&type_option, "abc", "", &field_type, &field);
|
||||
@ -49,7 +49,7 @@ mod tests {
|
||||
let field_type = FieldType::Number;
|
||||
let mut type_option = NumberTypeOption::new();
|
||||
type_option.format = NumberFormat::USD;
|
||||
let field = FieldBuilder::new(field_type.clone(), type_option.clone()).build();
|
||||
let field = FieldBuilder::new(field_type, type_option.clone()).build();
|
||||
|
||||
assert_number(
|
||||
&type_option,
|
||||
@ -71,7 +71,7 @@ mod tests {
|
||||
let field_type = FieldType::Number;
|
||||
let mut type_option = NumberTypeOption::new();
|
||||
type_option.format = NumberFormat::USD;
|
||||
let field = FieldBuilder::new(field_type.clone(), type_option.clone()).build();
|
||||
let field = FieldBuilder::new(field_type, type_option.clone()).build();
|
||||
|
||||
assert_number(&type_option, "€0.2", "$0.2", &field_type, &field);
|
||||
assert_number(&type_option, "-€0.2", "-$0.2", &field_type, &field);
|
||||
@ -85,7 +85,7 @@ mod tests {
|
||||
let field_type = FieldType::Number;
|
||||
let mut type_option = NumberTypeOption::new();
|
||||
type_option.format = NumberFormat::EUR;
|
||||
let field = FieldBuilder::new(field_type.clone(), type_option.clone()).build();
|
||||
let field = FieldBuilder::new(field_type, type_option.clone()).build();
|
||||
|
||||
assert_number(&type_option, "0.2", "€0,2", &field_type, &field);
|
||||
assert_number(&type_option, "1000", "€1.000", &field_type, &field);
|
||||
|
@ -12,7 +12,7 @@ mod tests {
|
||||
#[test]
|
||||
fn date_type_to_text_type() {
|
||||
let field_type = FieldType::DateTime;
|
||||
let field = FieldBuilder::new(field_type.clone(), DateTypeOption::test()).build();
|
||||
let field = FieldBuilder::new(field_type, DateTypeOption::test()).build();
|
||||
|
||||
assert_eq!(
|
||||
stringify_cell_data(
|
||||
@ -77,7 +77,7 @@ mod tests {
|
||||
options: vec![done_option.clone()],
|
||||
disable_color: false,
|
||||
};
|
||||
let field = FieldBuilder::new(field_type.clone(), single_select).build();
|
||||
let field = FieldBuilder::new(field_type, single_select).build();
|
||||
|
||||
assert_eq!(
|
||||
stringify_cell_data(
|
||||
@ -107,7 +107,7 @@ mod tests {
|
||||
let france_option_id = france.id;
|
||||
let argentina_option_id = argentina.id;
|
||||
|
||||
let field_rev = FieldBuilder::new(field_type.clone(), multi_select).build();
|
||||
let field_rev = FieldBuilder::new(field_type, multi_select).build();
|
||||
|
||||
assert_eq!(
|
||||
stringify_cell_data(
|
||||
|
@ -272,7 +272,7 @@ pub fn default_type_option_data_from_type(field_type: &FieldType) -> TypeOptionD
|
||||
FieldType::Number => NumberTypeOption::default().into(),
|
||||
FieldType::DateTime => DateTypeOption::default().into(),
|
||||
FieldType::LastEditedTime | FieldType::CreatedTime => TimestampTypeOption {
|
||||
field_type: field_type.clone(),
|
||||
field_type: *field_type,
|
||||
date_format: DateFormat::Friendly,
|
||||
time_format: TimeFormat::TwelveHour,
|
||||
include_time: true,
|
||||
|
@ -78,7 +78,7 @@ struct CellDataCacheKey(u64);
|
||||
impl CellDataCacheKey {
|
||||
pub fn new(field_rev: &Field, decoded_field_type: FieldType, cell: &Cell) -> Self {
|
||||
let mut hasher = DefaultHasher::new();
|
||||
if let Some(type_option_data) = field_rev.get_any_type_option(&decoded_field_type) {
|
||||
if let Some(type_option_data) = field_rev.get_any_type_option(decoded_field_type) {
|
||||
type_option_data.hash(&mut hasher);
|
||||
}
|
||||
hasher.write(field_rev.id.as_bytes());
|
||||
@ -141,7 +141,7 @@ where
|
||||
decoded_field_type: &FieldType,
|
||||
field: &Field,
|
||||
) -> FlowyResult<<Self as TypeOption>::CellData> {
|
||||
let key = CellDataCacheKey::new(field, decoded_field_type.clone(), cell);
|
||||
let key = CellDataCacheKey::new(field, *decoded_field_type, cell);
|
||||
if let Some(cell_data_cache) = self.cell_data_cache.as_ref() {
|
||||
let read_guard = cell_data_cache.read();
|
||||
if let Some(cell_data) = read_guard.get(key.as_ref()).cloned() {
|
||||
|
@ -117,7 +117,7 @@ impl std::convert::From<&Filter> for FilterType {
|
||||
Self {
|
||||
filter_id: filter.id.clone(),
|
||||
field_id: filter.field_id.clone(),
|
||||
field_type: filter.field_type.clone(),
|
||||
field_type: filter.field_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -127,7 +127,7 @@ impl std::convert::From<&FilterPB> for FilterType {
|
||||
Self {
|
||||
filter_id: filter.id.clone(),
|
||||
field_id: filter.field_id.clone(),
|
||||
field_type: filter.field_type.clone(),
|
||||
field_type: filter.field_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ fn default_field(field_str: String, is_primary: bool) -> Field {
|
||||
Field::new(
|
||||
gen_field_id(),
|
||||
field_str,
|
||||
field_type.clone().into(),
|
||||
field_type.into(),
|
||||
is_primary,
|
||||
)
|
||||
.with_type_option_data(field_type, type_option_data)
|
||||
|
@ -240,7 +240,7 @@ fn cmp_row(
|
||||
fields: &[Arc<Field>],
|
||||
cell_data_cache: &CellCache,
|
||||
) -> Ordering {
|
||||
let field_type = sort.field_type.clone();
|
||||
let field_type = sort.field_type;
|
||||
match fields
|
||||
.iter()
|
||||
.find(|field_rev| field_rev.id == sort.field_id)
|
||||
|
@ -109,7 +109,7 @@ impl From<&Sort> for SortType {
|
||||
Self {
|
||||
sort_id: data.id.clone(),
|
||||
field_id: data.field_id.clone(),
|
||||
field_type: data.field_type.clone(),
|
||||
field_type: data.field_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user