fix: don't use timestamp fields to make calendar (#3366)

This commit is contained in:
Richard Shiue 2023-09-13 19:11:46 +08:00 committed by GitHub
parent 1ca130d7de
commit a4681a4042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 12 deletions

View File

@ -558,8 +558,6 @@ impl FieldType {
pub fn is_date(&self) -> bool { pub fn is_date(&self) -> bool {
matches!(self, FieldType::DateTime) matches!(self, FieldType::DateTime)
|| matches!(self, FieldType::LastEditedTime)
|| matches!(self, FieldType::CreatedTime)
} }
pub fn is_single_select(&self) -> bool { pub fn is_single_select(&self) -> bool {

View File

@ -82,8 +82,6 @@ impl TypeCellData {
pub fn is_date(&self) -> bool { pub fn is_date(&self) -> bool {
self.field_type == FieldType::DateTime self.field_type == FieldType::DateTime
|| self.field_type == FieldType::LastEditedTime
|| self.field_type == FieldType::CreatedTime
} }
pub fn is_single_select(&self) -> bool { pub fn is_single_select(&self) -> bool {

View File

@ -51,7 +51,7 @@ impl DatabaseLayoutDepsResolver {
.lock() .lock()
.get_fields(None) .get_fields(None)
.into_iter() .into_iter()
.find(|field| FieldType::from(field.field_type).is_date()) .find(|field| FieldType::from(field.field_type) == FieldType::DateTime)
{ {
Some(field) => { Some(field) => {
let layout_setting = CalendarLayoutSetting::new(field.id).into(); let layout_setting = CalendarLayoutSetting::new(field.id).into();

View File

@ -184,7 +184,10 @@ impl CellDataDecoder for NumberTypeOption {
decoded_field_type: &FieldType, decoded_field_type: &FieldType,
_field: &Field, _field: &Field,
) -> FlowyResult<<Self as TypeOption>::CellData> { ) -> FlowyResult<<Self as TypeOption>::CellData> {
if decoded_field_type.is_date() { if decoded_field_type.is_date()
|| decoded_field_type.is_created_time()
|| decoded_field_type.is_last_edited_time()
{
return Ok(Default::default()); return Ok(Default::default());
} }

View File

@ -130,11 +130,8 @@ impl CellDataDecoder for TimestampTypeOption {
decoded_field_type: &FieldType, decoded_field_type: &FieldType,
_field: &Field, _field: &Field,
) -> FlowyResult<<Self as TypeOption>::CellData> { ) -> FlowyResult<<Self as TypeOption>::CellData> {
// Return default data if the type_option_cell_data is not FieldType::DateTime. // Return default data if the type_option_cell_data is not FieldType::CreatedTime nor FieldType::LastEditedTime
// It happens when switching from one field to another. if !decoded_field_type.is_last_edited_time() && !decoded_field_type.is_created_time() {
// For example:
// FieldType::RichText -> FieldType::DateTime, it will display empty content on the screen.
if !decoded_field_type.is_date() {
return Ok(Default::default()); return Ok(Default::default());
} }
@ -177,7 +174,7 @@ impl TypeOptionCellDataFilter for TimestampTypeOption {
field_type: &FieldType, field_type: &FieldType,
cell_data: &<Self as TypeOption>::CellData, cell_data: &<Self as TypeOption>::CellData,
) -> bool { ) -> bool {
if !field_type.is_date() { if !field_type.is_last_edited_time() && !field_type.is_created_time() {
return true; return true;
} }