From c0cebcca96b695998a10fee3e267475a5c4f18a3 Mon Sep 17 00:00:00 2001
From: alemi
Date: Mon, 13 May 2024 18:05:48 +0200
Subject: [PATCH] feat(web): better document view
---
web/src/components/object.rs | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/web/src/components/object.rs b/web/src/components/object.rs
index 4fcb38c1..3073ff7a 100644
--- a/web/src/components/object.rs
+++ b/web/src/components/object.rs
@@ -15,12 +15,12 @@ pub fn Attachment(
let (expand, set_expand) = create_signal(false);
let href = object.url().id().unwrap_or_default();
let media_type = object.media_type()
- .unwrap_or("image/png") // TODO weird defaulting to png?????
+ .unwrap_or("link") // TODO make it an Option rather than defaulting to link everywhere
.to_string();
let mut kind = media_type
.split('/')
.next()
- .unwrap_or("image")
+ .unwrap_or("link")
.to_string();
// TODO in theory we should match on document_type, but mastodon and misskey send all attachments
@@ -76,15 +76,29 @@ pub fn Attachment(
}.into_view(),
+ "link" =>
+ view! {
+
+
+ {Uri::pretty(&href)}
+
+
+ {object.name().map(|name| {
+ view! {
+ {name.to_string()}
+ }
+ })}
+ }.into_view(),
+
_ =>
view! {
{media_type}
-
- {object.name().unwrap_or_default().to_string()}
-
+ {object.name().map(|name| {
+ view! { {name.to_string()}
}
+ })}
}.into_view(),
}
@@ -130,11 +144,14 @@ pub fn Object(object: crate::Object) -> impl IntoView {
{post_inner}
}.into_view(),
// lemmy with Page, peertube with Video
- Some(apb::ObjectType::Document(_)) => view! {
+ Some(apb::ObjectType::Document(t)) => view! {
}.into_view(),
// wordpress, ... ?