feat(web): filter timelines, loop videos, open cws
This commit is contained in:
parent
c068822b3c
commit
227e9c625b
3 changed files with 49 additions and 33 deletions
|
@ -33,36 +33,51 @@ pub fn ActivityLine(activity: crate::Object) -> impl IntoView {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Item(item: crate::Object) -> impl IntoView {
|
pub fn Item(
|
||||||
|
item: crate::Object,
|
||||||
|
#[prop(optional)] sep: bool,
|
||||||
|
) -> impl IntoView {
|
||||||
|
let config = use_context::<Signal<crate::Config>>().expect("missing config context");
|
||||||
let id = item.id().unwrap_or_default().to_string();
|
let id = item.id().unwrap_or_default().to_string();
|
||||||
|
let sep = if sep { Some(view! { <hr /> }) } else { None };
|
||||||
match item.object_type() {
|
match item.object_type() {
|
||||||
// special case for placeholder activities
|
// special case for placeholder activities
|
||||||
Some(apb::ObjectType::Note) | Some(apb::ObjectType::Document(_)) =>
|
Some(apb::ObjectType::Note) | Some(apb::ObjectType::Document(_)) => (move || {
|
||||||
view! { <Object object=item /> }.into_view(),
|
if config.get().filters.orphans {
|
||||||
|
Some(view! { <Object object=item.clone() />{sep.clone()} })
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}).into_view(),
|
||||||
// everything else
|
// everything else
|
||||||
Some(apb::ObjectType::Activity(t)) => {
|
Some(apb::ObjectType::Activity(t)) => (move || {
|
||||||
let object_id = item.object().id().unwrap_or_default();
|
if config.get().filters.visible(apb::ObjectType::Activity(t)) {
|
||||||
let object = match t {
|
let object_id = item.object().id().unwrap_or_default();
|
||||||
apb::ActivityType::Create | apb::ActivityType::Announce =>
|
let object = match t {
|
||||||
CACHE.get(&object_id).map(|obj| {
|
apb::ActivityType::Create | apb::ActivityType::Announce =>
|
||||||
view! { <Object object=obj /> }
|
CACHE.get(&object_id).map(|obj| {
|
||||||
}.into_view()),
|
view! { <Object object=obj /> }
|
||||||
apb::ActivityType::Follow =>
|
}.into_view()),
|
||||||
CACHE.get(&object_id).map(|obj| {
|
apb::ActivityType::Follow =>
|
||||||
view! {
|
CACHE.get(&object_id).map(|obj| {
|
||||||
<div class="ml-1">
|
view! {
|
||||||
<ActorBanner object=obj />
|
<div class="ml-1">
|
||||||
<FollowRequestButtons activity_id=id actor_id=object_id />
|
<ActorBanner object=obj />
|
||||||
</div>
|
<FollowRequestButtons activity_id=id.clone() actor_id=object_id />
|
||||||
}
|
</div>
|
||||||
}.into_view()),
|
}
|
||||||
_ => None,
|
}.into_view()),
|
||||||
};
|
_ => None,
|
||||||
view! {
|
};
|
||||||
<ActivityLine activity=item />
|
Some(view! {
|
||||||
{object}
|
<ActivityLine activity=item.clone() />
|
||||||
}.into_view()
|
{object}
|
||||||
},
|
{sep.clone()}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}).into_view(),
|
||||||
// should never happen
|
// should never happen
|
||||||
_ => view! { <p><code>type not implemented</code></p> }.into_view(),
|
_ => view! { <p><code>type not implemented</code></p> }.into_view(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub fn Attachment(
|
||||||
#[prop(optional)]
|
#[prop(optional)]
|
||||||
sensitive: bool
|
sensitive: bool
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
|
let config = use_context::<Signal<crate::Config>>().expect("missing config context");
|
||||||
let (expand, set_expand) = create_signal(false);
|
let (expand, set_expand) = create_signal(false);
|
||||||
let href = object.url().id().unwrap_or_default();
|
let href = object.url().id().unwrap_or_default();
|
||||||
let media_type = object.media_type()
|
let media_type = object.media_type()
|
||||||
|
@ -47,7 +48,7 @@ pub fn Attachment(
|
||||||
on:click=move |_| set_expand.set(!expand.get())
|
on:click=move |_| set_expand.set(!expand.get())
|
||||||
title={object.name().unwrap_or_default().to_string()}
|
title={object.name().unwrap_or_default().to_string()}
|
||||||
>
|
>
|
||||||
<video controls loop class="attachment" class:expand=expand >
|
<video controls class="attachment" class:expand=expand prop:loop=move || config.get().loop_videos >
|
||||||
{move || if sensitive && !expand.get() { None } else { Some(view! { <source src={_href.clone()} type={media_type.clone()} /> }) }}
|
{move || if sensitive && !expand.get() { None } else { Some(view! { <source src={_href.clone()} type={media_type.clone()} /> }) }}
|
||||||
<a href={href.clone()} target="_blank">video clip</a>
|
<a href={href.clone()} target="_blank">video clip</a>
|
||||||
</video>
|
</video>
|
||||||
|
@ -58,7 +59,7 @@ pub fn Attachment(
|
||||||
"audio" =>
|
"audio" =>
|
||||||
view! {
|
view! {
|
||||||
<p class="center">
|
<p class="center">
|
||||||
<audio controls class="w-100">
|
<audio controls class="w-100" prop:loop=move || config.get().loop_videos >
|
||||||
<source src={href.clone()} type={media_type} />
|
<source src={href.clone()} type={media_type} />
|
||||||
<a href={href} target="_blank">audio clip</a>
|
<a href={href} target="_blank">audio clip</a>
|
||||||
</audio>
|
</audio>
|
||||||
|
@ -106,7 +107,7 @@ pub fn Object(object: crate::Object) -> impl IntoView {
|
||||||
Some(view! { <div class="pb-1"></div> })
|
Some(view! { <div class="pb-1"></div> })
|
||||||
};
|
};
|
||||||
let post_inner = view! {
|
let post_inner = view! {
|
||||||
<Summary summary=object.summary().map(|x| x.to_string()) open=false >
|
<Summary summary=object.summary().map(|x| x.to_string()) >
|
||||||
<p inner_html={content}></p>
|
<p inner_html={content}></p>
|
||||||
{attachments_padding}
|
{attachments_padding}
|
||||||
{attachments}
|
{attachments}
|
||||||
|
@ -152,11 +153,12 @@ pub fn Object(object: crate::Object) -> impl IntoView {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Summary(summary: Option<String>, open: bool, children: Children) -> impl IntoView {
|
pub fn Summary(summary: Option<String>, children: Children) -> impl IntoView {
|
||||||
|
let config = use_context::<Signal<crate::Config>>().expect("missing config context");
|
||||||
match summary.filter(|x| !x.is_empty()) {
|
match summary.filter(|x| !x.is_empty()) {
|
||||||
None => children().into_view(),
|
None => children().into_view(),
|
||||||
Some(summary) => view! {
|
Some(summary) => view! {
|
||||||
<details class="pa-s" prop:open=open>
|
<details class="pa-s" prop:open=move || !config.get().collapse_content_warnings>
|
||||||
<summary>
|
<summary>
|
||||||
<code class="cw center color ml-s w-100">{summary}</code>
|
<code class="cw center color ml-s w-100">{summary}</code>
|
||||||
</summary>
|
</summary>
|
||||||
|
|
|
@ -140,8 +140,7 @@ pub fn TimelineFeed(tl: Timeline) -> impl IntoView {
|
||||||
children=move |id: String| {
|
children=move |id: String| {
|
||||||
match CACHE.get(&id) {
|
match CACHE.get(&id) {
|
||||||
Some(i) => view! {
|
Some(i) => view! {
|
||||||
<Item item=i />
|
<Item item=i sep=true />
|
||||||
<hr />
|
|
||||||
}.into_view(),
|
}.into_view(),
|
||||||
None => view! {
|
None => view! {
|
||||||
<p><code>{id}</code>" "[<a href={uri}>go</a>]</p>
|
<p><code>{id}</code>" "[<a href={uri}>go</a>]</p>
|
||||||
|
|
Loading…
Reference in a new issue