Преглед на файлове

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

Richard Shiue преди 1 година
родител
ревизия
a4681a4042

+ 0 - 2
frontend/rust-lib/flowy-database2/src/entities/field_entities.rs

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

+ 0 - 2
frontend/rust-lib/flowy-database2/src/services/cell/type_cell_data.rs

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

+ 1 - 1
frontend/rust-lib/flowy-database2/src/services/database_view/layout_deps.rs

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

+ 4 - 1
frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs

@@ -184,7 +184,10 @@ impl CellDataDecoder for NumberTypeOption {
     decoded_field_type: &FieldType,
     _field: &Field,
   ) -> 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());
     }
 

+ 3 - 6
frontend/rust-lib/flowy-database2/src/services/field/type_options/timestamp_type_option/timestamp_type_option.rs

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