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,14 +33,25 @@ 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 || {
|
||||||
|
if config.get().filters.visible(apb::ObjectType::Activity(t)) {
|
||||||
let object_id = item.object().id().unwrap_or_default();
|
let object_id = item.object().id().unwrap_or_default();
|
||||||
let object = match t {
|
let object = match t {
|
||||||
apb::ActivityType::Create | apb::ActivityType::Announce =>
|
apb::ActivityType::Create | apb::ActivityType::Announce =>
|
||||||
|
@ -52,17 +63,21 @@ pub fn Item(item: crate::Object) -> impl IntoView {
|
||||||
view! {
|
view! {
|
||||||
<div class="ml-1">
|
<div class="ml-1">
|
||||||
<ActorBanner object=obj />
|
<ActorBanner object=obj />
|
||||||
<FollowRequestButtons activity_id=id actor_id=object_id />
|
<FollowRequestButtons activity_id=id.clone() actor_id=object_id />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}.into_view()),
|
}.into_view()),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
view! {
|
Some(view! {
|
||||||
<ActivityLine activity=item />
|
<ActivityLine activity=item.clone() />
|
||||||
{object}
|
{object}
|
||||||
}.into_view()
|
{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