chore: fix warnings

This commit is contained in:
appflowy 2022-07-06 11:59:05 +08:00
parent 5b504740ef
commit 3845a75d61
11 changed files with 40 additions and 42 deletions

View File

@ -28,7 +28,7 @@ macro_rules! impl_def_and_def_mut {
impl $target {
#[allow(dead_code)]
pub fn into_inner(&mut self) -> Vec<$item> {
::std::mem::replace(&mut self.items, vec![])
::std::mem::take(&mut self.items)
}
#[allow(dead_code)]

View File

@ -43,8 +43,8 @@ const YES: &str = "Yes";
const NO: &str = "No";
impl CellFilterOperation<GridCheckboxFilter, CheckboxCellData> for CheckboxTypeOption {
fn apply_filter(&self, cell_data: CheckboxCellData, filter: &GridCheckboxFilter) -> bool {
return false;
fn apply_filter(&self, _cell_data: CheckboxCellData, _filter: &GridCheckboxFilter) -> bool {
false
}
}
@ -53,7 +53,7 @@ impl CellDataOperation<String> for CheckboxTypeOption {
&self,
cell_data: T,
decoded_field_type: &FieldType,
field_rev: &FieldRevision,
_field_rev: &FieldRevision,
) -> FlowyResult<DecodedCellData>
where
T: Into<String>,

View File

@ -118,8 +118,8 @@ impl DateTypeOption {
}
impl CellFilterOperation<GridDateFilter, AnyCellData> for DateTypeOption {
fn apply_filter(&self, cell_data: AnyCellData, filter: &GridDateFilter) -> bool {
return false;
fn apply_filter(&self, _cell_data: AnyCellData, _filter: &GridDateFilter) -> bool {
false
}
}
@ -128,7 +128,7 @@ impl CellDataOperation<String> for DateTypeOption {
&self,
cell_data: T,
decoded_field_type: &FieldType,
field_rev: &FieldRevision,
_field_rev: &FieldRevision,
) -> FlowyResult<DecodedCellData>
where
T: Into<String>,

View File

@ -141,9 +141,9 @@ impl NumberTypeOption {
}
}
impl CellFilterOperation<GridNumberFilter, AnyCellData> for NumberTypeOption {
fn apply_filter(&self, any_cell_data: AnyCellData, filter: &GridNumberFilter) -> bool {
let number_cell_data = NumberCellData::from_number_type_option(self, any_cell_data);
return false;
fn apply_filter(&self, any_cell_data: AnyCellData, _filter: &GridNumberFilter) -> bool {
let _number_cell_data = NumberCellData::from_number_type_option(self, any_cell_data);
false
}
}
@ -152,7 +152,7 @@ impl CellDataOperation<String> for NumberTypeOption {
&self,
cell_data: T,
decoded_field_type: &FieldType,
field_rev: &FieldRevision,
_field_rev: &FieldRevision,
) -> FlowyResult<DecodedCellData>
where
T: Into<String>,

View File

@ -98,8 +98,8 @@ impl SelectOptionOperation for SingleSelectTypeOption {
}
impl CellFilterOperation<GridSelectOptionFilter, SelectOptionIds> for SingleSelectTypeOption {
fn apply_filter(&self, cell_data: SelectOptionIds, filter: &GridSelectOptionFilter) -> bool {
return false;
fn apply_filter(&self, _cell_data: SelectOptionIds, _filter: &GridSelectOptionFilter) -> bool {
false
}
}
@ -108,7 +108,7 @@ impl CellDataOperation<String> for SingleSelectTypeOption {
&self,
cell_data: T,
decoded_field_type: &FieldType,
field_rev: &FieldRevision,
_field_rev: &FieldRevision,
) -> FlowyResult<DecodedCellData>
where
T: Into<String>,
@ -201,8 +201,8 @@ impl SelectOptionOperation for MultiSelectTypeOption {
}
}
impl CellFilterOperation<GridSelectOptionFilter, SelectOptionIds> for MultiSelectTypeOption {
fn apply_filter(&self, cell_data: SelectOptionIds, filter: &GridSelectOptionFilter) -> bool {
return false;
fn apply_filter(&self, _cell_data: SelectOptionIds, _filter: &GridSelectOptionFilter) -> bool {
false
}
}
impl CellDataOperation<String> for MultiSelectTypeOption {
@ -210,7 +210,7 @@ impl CellDataOperation<String> for MultiSelectTypeOption {
&self,
cell_data: T,
decoded_field_type: &FieldType,
field_rev: &FieldRevision,
_field_rev: &FieldRevision,
) -> FlowyResult<DecodedCellData>
where
T: Into<String>,

View File

@ -33,8 +33,8 @@ pub struct RichTextTypeOption {
impl_type_option!(RichTextTypeOption, FieldType::RichText);
impl CellFilterOperation<GridTextFilter, TextCellData> for RichTextTypeOption {
fn apply_filter(&self, cell_data: TextCellData, filter: &GridTextFilter) -> bool {
return false;
fn apply_filter(&self, _cell_data: TextCellData, _filter: &GridTextFilter) -> bool {
false
}
}

View File

@ -36,8 +36,8 @@ pub struct URLTypeOption {
impl_type_option!(URLTypeOption, FieldType::URL);
impl CellFilterOperation<GridTextFilter, URLCellData> for URLTypeOption {
fn apply_filter(&self, cell_data: URLCellData, filter: &GridTextFilter) -> bool {
return false;
fn apply_filter(&self, _cell_data: URLCellData, _filter: &GridTextFilter) -> bool {
false
}
}
@ -46,7 +46,7 @@ impl CellDataOperation<EncodedCellData<URLCellData>> for URLTypeOption {
&self,
cell_data: T,
decoded_field_type: &FieldType,
field_rev: &FieldRevision,
_field_rev: &FieldRevision,
) -> FlowyResult<DecodedCellData>
where
T: Into<EncodedCellData<URLCellData>>,
@ -123,7 +123,7 @@ impl FromStr for URLCellData {
impl std::convert::From<AnyCellData> for URLCellData {
fn from(any_cell_data: AnyCellData) -> Self {
URLCellData::from_str(&any_cell_data.cell_data).unwrap_or(URLCellData::default())
URLCellData::from_str(&any_cell_data.cell_data).unwrap_or_default()
}
}

View File

@ -1,6 +1,5 @@
use crate::entities::{
FieldType, GridBlockChangeset, GridCheckboxFilter, GridDateFilter, GridNumberFilter, GridRowId,
GridSelectOptionFilter, GridTextFilter, InsertedRow,
FieldType, GridCheckboxFilter, GridDateFilter, GridNumberFilter, GridSelectOptionFilter, GridTextFilter,
};
use dashmap::DashMap;
@ -35,27 +34,26 @@ impl std::ops::Deref for FilterResultCache {
#[derive(Default)]
pub(crate) struct FilterResult {
pub(crate) row_id: String,
#[allow(dead_code)]
pub(crate) row_index: i32,
pub(crate) visible_by_field_id: HashMap<FilterId, bool>,
}
impl FilterResult {
pub(crate) fn new(index: i32, row_rev: &RowRevision) -> Self {
pub(crate) fn new(index: i32, _row_rev: &RowRevision) -> Self {
Self {
row_index: index,
row_id: row_rev.id.clone(),
visible_by_field_id: HashMap::new(),
}
}
pub(crate) fn is_visible(&self) -> bool {
for (_, visible) in &self.visible_by_field_id {
for visible in self.visible_by_field_id.values() {
if visible == &false {
return false;
}
}
return true;
true
}
}

View File

@ -1,5 +1,5 @@
use crate::dart_notification::{send_dart_notification, GridNotification};
use crate::entities::{FieldType, GridBlockChangeset, GridTextFilter};
use crate::entities::{FieldType, GridBlockChangeset};
use crate::services::block_manager::GridBlockManager;
use crate::services::field::{
CheckboxTypeOption, DateTypeOption, MultiSelectTypeOption, NumberTypeOption, RichTextTypeOption,
@ -9,15 +9,15 @@ use crate::services::filter::filter_cache::{
reload_filter_cache, FilterCache, FilterId, FilterResult, FilterResultCache,
};
use crate::services::grid_editor_task::GridServiceTaskScheduler;
use crate::services::row::{AnyCellData, CellDataOperation, CellFilterOperation, GridBlockSnapshot};
use crate::services::row::{AnyCellData, CellFilterOperation, GridBlockSnapshot};
use crate::services::tasks::{FilterTaskContext, Task, TaskContent};
use dashmap::mapref::one::{Ref, RefMut};
use flowy_error::FlowyResult;
use flowy_grid_data_model::revision::{CellRevision, FieldId, FieldRevision, RowRevision};
use flowy_sync::client_grid::GridRevisionPad;
use flowy_sync::entities::grid::GridSettingChangesetParams;
use rayon::prelude::*;
use std::borrow::Cow;
use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::RwLock;
@ -162,7 +162,7 @@ fn filter_row(
}
}
}
return None;
None
}
// Return None if there is no change in this cell after applying the filter
@ -193,14 +193,14 @@ fn filter_cell(
Some(
field_rev
.get_type_option_entry::<NumberTypeOption>(field_type_rev)?
.apply_filter(any_cell_data.into(), filter.value()),
.apply_filter(any_cell_data, filter.value()),
)
}),
FieldType::DateTime => filter_cache.date_filter.get(&filter_id).and_then(|filter| {
Some(
field_rev
.get_type_option_entry::<DateTypeOption>(field_type_rev)?
.apply_filter(any_cell_data.into(), filter.value()),
.apply_filter(any_cell_data, filter.value()),
)
}),
FieldType::SingleSelect => filter_cache.select_option_filter.get(&filter_id).and_then(|filter| {
@ -237,7 +237,7 @@ fn filter_cell(
match filter_result.visible_by_field_id.get(&filter_id) {
None => {
if is_visible {
return None;
None
} else {
filter_result.visible_by_field_id.insert(filter_id, is_visible);
Some(())

View File

@ -12,7 +12,7 @@ pub fn create_text_field(grid_id: &str) -> (InsertFieldParams, FieldRevision) {
let cloned_field_rev = field_rev.clone();
let type_option_data = field_rev
.get_type_option_entry::<RichTextTypeOption>(field_rev.field_type_rev.clone())
.get_type_option_entry::<RichTextTypeOption>(field_rev.field_type_rev)
.unwrap()
.protobuf_bytes()
.to_vec();
@ -45,7 +45,7 @@ pub fn create_single_select_field(grid_id: &str) -> (InsertFieldParams, FieldRev
let field_rev = FieldBuilder::new(single_select).name("Name").visibility(true).build();
let cloned_field_rev = field_rev.clone();
let type_option_data = field_rev
.get_type_option_entry::<SingleSelectTypeOption>(field_rev.field_type_rev.clone())
.get_type_option_entry::<SingleSelectTypeOption>(field_rev.field_type_rev)
.unwrap()
.protobuf_bytes()
.to_vec();
@ -54,7 +54,7 @@ pub fn create_single_select_field(grid_id: &str) -> (InsertFieldParams, FieldRev
id: field_rev.id,
name: field_rev.name,
desc: field_rev.desc,
field_type,
field_type: field_rev.field_type_rev.into(),
frozen: field_rev.frozen,
visibility: field_rev.visibility,
width: field_rev.width,

View File

@ -137,7 +137,7 @@ async fn grid_row_add_date_cell_test() {
}
let context = builder.build();
let date_field = date_field.unwrap();
let cell_rev = context.cell_by_field_id.get(&date_field.id).unwrap().clone();
let cell_rev = context.cell_by_field_id.get(&date_field.id).unwrap();
assert_eq!(
decode_any_cell_data(cell_rev, &date_field)
.parse::<DateCellData>()