refactor!: remove .get_type from BlockValue

This commit is contained in:
Gustavo "Guz" L. de Mello
2024-04-25 10:38:41 -03:00
parent cba408d562
commit dc1550dcc6
2 changed files with 4 additions and 12 deletions

View File

@@ -13,17 +13,6 @@ pub enum BlockValue {
Audio(BlockAudio),
Video(BlockVideo),
}
impl BlockValue {
pub fn get_type(&self) -> String {
String::from(match &self {
BlockValue::Text(_) => "text",
BlockValue::Image(_) => "image",
BlockValue::Link(_) => "link",
BlockValue::Audio(_) => "audio",
BlockValue::Video(_) => "video",
})
}
}
#[derive(Debug, Deserialize, Serialize, Clone)]
#[serde(rename_all = "snake_case")]

View File

@@ -62,7 +62,10 @@ impl Post {
}
pub fn fold_content(mut self) -> Self {
// TODO: Some form of folding also the layout of the npf
let groups = self.content.iter_mut().group_by(|c| c.get_type() == "text");
let groups = self.content.iter_mut().group_by(|c| match c {
BlockValue::Text(_) => true,
_ => false,
});
self.content = groups
.into_iter()
.map(|a| {