feat(web): use tabs on actors page too

rather than weird good-luck-finding-it button next to their name
This commit is contained in:
əlemi 2024-12-26 22:10:29 +01:00
parent d2477339e7
commit a09795246b
Signed by: alemi
GPG key ID: A4895B84D311642C
4 changed files with 37 additions and 9 deletions

View file

@ -27,11 +27,13 @@ pub fn FollowList(outgoing: bool) -> impl IntoView {
}
);
view! {
<code class="cw center color mt-1 mr-3 ml-3"><span class="emoji">{symbol}</span>" "<b>{follow___}</b></code>
<div class="tl ml-3-r mr-3-r pl-1 pt-1 pb-1">
{move || match resource.get() {
None => view! { <Loader /> }.into_view(),
Some(Err(e)) => view! { <p class="center">could not load {follow___}: {e}</p> }.into_view(),
Some(Err(e)) => {
tracing::error!("could not load followers: {e}");
view! { <code class="cw center color">{follow___}" unavailable"</code> }.into_view()
},
Some(Ok(mut arr)) => {
// TODO cheap fix: server gives us follows from oldest to newest
// but it's way more convenient to have them other way around

View file

@ -1,6 +1,6 @@
use leptos::*;
use leptos_router::*;
use crate::{getters::Getter, prelude::*, FALLBACK_IMAGE_URL};
use crate::{app::FeedRoute, getters::Getter, prelude::*, FALLBACK_IMAGE_URL};
use apb::{ActivityMut, Actor, Base, Object, ObjectMut, Shortcuts};
@ -8,6 +8,7 @@ use apb::{ActivityMut, Actor, Base, Object, ObjectMut, Shortcuts};
pub fn ActorHeader() -> impl IntoView {
let params = use_params::<IdParam>();
let auth = use_context::<Auth>().expect("missing auth context");
let matched_route = use_context::<ReadSignal<crate::app::FeedRoute>>().expect("missing route context");
let actor = create_local_resource(
move || params.get().ok().and_then(|x| x.id).unwrap_or_default(),
move |id| {
@ -99,6 +100,18 @@ pub fn ActorHeader() -> impl IntoView {
<table class="fields center w-100 pa-s" style="margin: auto; table-layout: fixed;">{fields}</table>
</p>
</div>
<p class="mt-2">
<span class:tab-active=move || matches!(matched_route.get(), FeedRoute::User)>
<a class="clean" href=web_path.clone()><span class="emoji ml-2">"🖂 "</span>"statuses"</a>
</span>
<span style="float: right" class:tab-active=move || matches!(matched_route.get(), FeedRoute::Followers)>
<a class="clean" href=format!("{web_path}/followers")><span class="emoji ml-2">"📢 "</span>"followers"</a>
</span>
<span style="float: right" class:tab-active=move || matches!(matched_route.get(), FeedRoute::Following)>
<a class="clean" href=format!("{web_path}/following")><span class="emoji ml-2">"👥 "</span>"following"</a>
</span>
</p>
<hr class="color" />
<Outlet />
}.into_view()
},

View file

@ -14,9 +14,6 @@ pub fn ActorPosts() -> impl IntoView {
}
});
view! {
<code class="cw color center mt-1 mb-1 ml-3 mr-3">
<span class="emoji">"🖂"</span>" "<b>posts</b>
</code>
<Feed tl=feeds.user />
}
}

View file

@ -210,7 +210,7 @@ pub fn App() -> impl IntoView {
#[derive(Debug, Clone, Copy)]
pub(crate) enum FeedRoute {
Home, Global, Server, Notifications, User, Replies, Context
Home, Global, Server, Notifications, User, Following, Followers, Likes, Replies, Context
}
#[component]
@ -238,8 +238,24 @@ fn Scrollable() -> impl IntoView {
set_route.set(FeedRoute::Notifications);
Some(feeds.notifications)
} else if path.starts_with("/web/actors") {
match path.split('/').nth(4) {
Some("following") => {
set_route.set(FeedRoute::Following);
None
},
Some("followers") => {
set_route.set(FeedRoute::Followers);
None
},
Some("likes") => {
set_route.set(FeedRoute::Likes);
None
},
_ => {
set_route.set(FeedRoute::User);
Some(feeds.user)
},
}
} else if path.starts_with("/web/objects") {
if matches!(path.split('/').nth(4), Some("replies")) {
set_route.set(FeedRoute::Replies);