URL mime hosted completeness

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-02-20 14:11:34 -05:00
parent 33fdf647e3
commit 9592452757
3 changed files with 48 additions and 9 deletions

View File

@@ -8,7 +8,7 @@ use egui::{Color32, Hyperlink, Image, RichText};
use nostrdb::{BlockType, Mention, Ndb, Note, NoteKey, Transaction};
use tracing::warn;
use notedeck::{Images, NoteCache};
use notedeck::{supported_mime_hosted_at_url, Images, NoteCache};
pub struct NoteContents<'a> {
ndb: &'a Ndb,
@@ -127,10 +127,6 @@ pub fn render_note_preview(
.inner
}
fn is_image_link(url: &str) -> bool {
url.ends_with("png") || url.ends_with("jpg") || url.ends_with("jpeg")
}
#[allow(clippy::too_many_arguments)]
fn render_note_contents(
ui: &mut egui::Ui,
@@ -212,9 +208,12 @@ fn render_note_contents(
}
BlockType::Url => {
let lower_url = block.as_str().to_lowercase();
if !hide_media && is_image_link(&lower_url) {
images.push(block.as_str().to_string());
if !hide_media {
let url = block.as_str().to_string();
if supported_mime_hosted_at_url(&mut img_cache.urls, &url) {
images.push(url);
}
} else {
#[cfg(feature = "profiling")]
puffin::profile_scope!("url contents");