refactor!: remove .get_type from BlockValue
This commit is contained in:
@@ -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")]
|
||||
|
||||
@@ -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| {
|
||||
|
||||
Reference in New Issue
Block a user