More clean up.

This commit is contained in:
Thomas Gideon 2023-07-15 21:30:14 -04:00
parent c90495a985
commit 17e99518ce
3 changed files with 31 additions and 23 deletions

View file

@ -1,7 +1,6 @@
use anyhow::Result;
use chrono::Local;
use html2md::parse_html;
use log::debug;
use megalodon::{
entities::{Account, Attachment, Status},
response::Response,
@ -46,7 +45,7 @@ pub(super) async fn format_status(
"{}{}",
ancestor,
if !thread.is_empty() {
thread
format!("\n{}", thread)
} else {
String::default()
}
@ -55,25 +54,20 @@ pub(super) async fn format_status(
fn format_attachments(depth: usize, attachments: &[Attachment]) -> String {
let prefix = vec![">"; depth].join("");
debug!("Attachments {:?}", attachments);
if attachments.is_empty() {
String::default()
} else {
let mut editor = DefaultEditor::new().unwrap();
attachments
.iter()
.map(|a| {
Url::parse(&a.url).unwrap().open();
let mut editor = DefaultEditor::new().unwrap();
let src = if let Ok(line) = editor.readline("Filename: ") {
line
} else {
a.url.clone()
};
format!(
"
{} <img src=\"{}\" />",
prefix, src
)
format!("{} <img src=\"{}\" />", prefix, src)
})
.collect::<Vec<String>>()
.join("\n")