Skip to content

Commit 95edca3

Browse files
committed
chore: fix media type option
1 parent e114e85 commit 95edca3

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

collab-database/src/fields/type_option/date_type_option.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@ impl TypeOptionCellReader for DateTypeOption {
101101
}
102102
}
103103

104-
fn numeric_cell(&self, cell: &Cell) -> Option<f64> {
105-
let cell_data = DateCellData::from(cell);
106-
cell_data.timestamp.map(|timestamp| timestamp as f64)
104+
fn numeric_cell(&self, _cell: &Cell) -> Option<f64> {
105+
None
107106
}
108107

109108
fn convert_raw_cell_data(&self, text: &str) -> String {

collab-database/src/fields/type_option/media_type_option.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ impl TypeOptionCellReader for MediaTypeOption {
4343
}
4444

4545
fn convert_raw_cell_data(&self, text: &str) -> String {
46-
let data = MediaCellData::from(text.to_string());
47-
data
48-
.files
49-
.into_iter()
50-
.map(|file| file.name)
51-
.collect::<Vec<_>>()
52-
.join(", ")
46+
match serde_json::from_str::<MediaCellData>(text) {
47+
Ok(value) => value.to_string(),
48+
Err(_) => "".to_string(),
49+
}
5350
}
5451
}
5552

@@ -136,21 +133,6 @@ impl From<MediaCellData> for Cell {
136133
}
137134
}
138135

139-
impl From<String> for MediaCellData {
140-
fn from(s: String) -> Self {
141-
if s.is_empty() {
142-
return MediaCellData { files: vec![] };
143-
}
144-
145-
let files = s
146-
.split(", ")
147-
.map(|file: &str| serde_json::from_str::<MediaFile>(file).unwrap_or_default())
148-
.collect::<Vec<_>>();
149-
150-
MediaCellData { files }
151-
}
152-
}
153-
154136
impl ToString for MediaCellData {
155137
fn to_string(&self) -> String {
156138
self

collab-database/src/fields/type_option/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ pub trait TypeOptionCellReader {
143143
}
144144

145145
/// Returns the numeric value of the cell. If the value is not numeric, returns `None`.
146+
/// Currently, it's used to calculate the sum of the numeric cell values.
146147
fn numeric_cell(&self, cell: &Cell) -> Option<f64>;
147148

148149
/// Convert the value stored in given key:[CELL_DATA] into a readable text

0 commit comments

Comments
 (0)