feat(web): prefetch and inline quote posts
finally!!!
This commit is contained in:
parent
44232ede58
commit
99abc2e71a
5 changed files with 36 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -4958,7 +4958,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "upub-web"
|
name = "upub-web"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apb",
|
"apb",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "upub-web"
|
name = "upub-web"
|
||||||
version = "0.4.0"
|
version = "0.4.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = [ "alemi <me@alemi.dev>" ]
|
authors = [ "alemi <me@alemi.dev>" ]
|
||||||
description = "web frontend for upub"
|
description = "web frontend for upub"
|
||||||
|
|
|
@ -136,6 +136,13 @@
|
||||||
div.sep-top {
|
div.sep-top {
|
||||||
border-top: 2px solid rgba(var(--accent-rgb), 0.45);
|
border-top: 2px solid rgba(var(--accent-rgb), 0.45);
|
||||||
}
|
}
|
||||||
|
div.quote {
|
||||||
|
border: 2px dotted var(--background-dim);
|
||||||
|
margin-top: 1em;
|
||||||
|
margin-left: 1em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
hr.sticky {
|
hr.sticky {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
|
|
@ -50,9 +50,19 @@ pub fn Object(object: crate::Object) -> impl IntoView {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let quote_badge = object.quote_url()
|
let quote_block = object.quote_url()
|
||||||
.id()
|
.id()
|
||||||
.ok()
|
.ok()
|
||||||
|
.and_then(|x| {
|
||||||
|
Some(view! {
|
||||||
|
<div class="quote">
|
||||||
|
<Object object=crate::cache::OBJECTS.get(&x)? />
|
||||||
|
</div>
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
let quote_badge = object.quote_url()
|
||||||
|
.id()
|
||||||
.map(|x| {
|
.map(|x| {
|
||||||
let href = Uri::web(U::Object, &x);
|
let href = Uri::web(U::Object, &x);
|
||||||
view! {
|
view! {
|
||||||
|
@ -60,12 +70,13 @@ pub fn Object(object: crate::Object) -> impl IntoView {
|
||||||
<span class="border-button ml-s" >
|
<span class="border-button ml-s" >
|
||||||
<code class="color mr-s">">"</code>
|
<code class="color mr-s">">"</code>
|
||||||
<small class="mr-s">
|
<small class="mr-s">
|
||||||
RE
|
quote
|
||||||
</small>
|
</small>
|
||||||
</span>
|
</span>
|
||||||
</a>" "
|
</a>" "
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
.ok();
|
||||||
|
|
||||||
let tag_badges = object.tag()
|
let tag_badges = object.tag()
|
||||||
.flat()
|
.flat()
|
||||||
|
@ -143,7 +154,10 @@ pub fn Object(object: crate::Object) -> impl IntoView {
|
||||||
let post = match object.object_type() {
|
let post = match object.object_type() {
|
||||||
// mastodon, pleroma, misskey
|
// mastodon, pleroma, misskey
|
||||||
Ok(apb::ObjectType::Note) => view! {
|
Ok(apb::ObjectType::Note) => view! {
|
||||||
<article class="tl">{post_inner}</article>
|
<article class="tl">
|
||||||
|
{post_inner}
|
||||||
|
{quote_block}
|
||||||
|
</article>
|
||||||
}.into_view(),
|
}.into_view(),
|
||||||
// lemmy with Page, peertube with Video
|
// lemmy with Page, peertube with Video
|
||||||
Ok(apb::ObjectType::Document(t)) => view! {
|
Ok(apb::ObjectType::Document(t)) => view! {
|
||||||
|
@ -154,6 +168,7 @@ pub fn Object(object: crate::Object) -> impl IntoView {
|
||||||
<b>{object.name().unwrap_or_default().to_string()}</b>
|
<b>{object.name().unwrap_or_default().to_string()}</b>
|
||||||
</h4>
|
</h4>
|
||||||
{post_inner}
|
{post_inner}
|
||||||
|
{quote_block}
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
}.into_view(),
|
}.into_view(),
|
||||||
|
@ -163,12 +178,14 @@ pub fn Object(object: crate::Object) -> impl IntoView {
|
||||||
<h3>{object.name().unwrap_or_default().to_string()}</h3>
|
<h3>{object.name().unwrap_or_default().to_string()}</h3>
|
||||||
<hr />
|
<hr />
|
||||||
{post_inner}
|
{post_inner}
|
||||||
|
{quote_block}
|
||||||
</article>
|
</article>
|
||||||
}.into_view(),
|
}.into_view(),
|
||||||
// everything else
|
// everything else
|
||||||
Ok(t) => view! {
|
Ok(t) => view! {
|
||||||
<h3>{t.as_ref().to_string()}</h3>
|
<h3>{t.as_ref().to_string()}</h3>
|
||||||
{post_inner}
|
{post_inner}
|
||||||
|
{quote_block}
|
||||||
}.into_view(),
|
}.into_view(),
|
||||||
// object without type?
|
// object without type?
|
||||||
Err(_) => view! { <code>missing object type</code> }.into_view(),
|
Err(_) => view! { <code>missing object type</code> }.into_view(),
|
||||||
|
|
|
@ -126,6 +126,12 @@ pub async fn process_activities(activities: Vec<serde_json::Value>, auth: Auth)
|
||||||
if let Ok(attributed_to) = object.attributed_to().id() {
|
if let Ok(attributed_to) = object.attributed_to().id() {
|
||||||
actors_seen.insert(attributed_to);
|
actors_seen.insert(attributed_to);
|
||||||
}
|
}
|
||||||
|
if let Ok(quote_id) = object.quote_url().id() {
|
||||||
|
if !gonna_fetch.contains("e_id) {
|
||||||
|
gonna_fetch.insert(quote_id.clone());
|
||||||
|
sub_tasks.push(Box::pin(fetch_and_update_with_user(U::Object, quote_id, auth)));
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Ok(object_uri) = object.id() {
|
if let Ok(object_uri) = object.id() {
|
||||||
cache::OBJECTS.store(&object_uri, Arc::new(object.clone()));
|
cache::OBJECTS.store(&object_uri, Arc::new(object.clone()));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue