feat(web): per-user timeline, proper scrollboxes

This commit is contained in:
əlemi 2024-04-16 08:02:03 +02:00
parent 5de3e6622f
commit 964b45e50b
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 82 additions and 67 deletions

View file

@ -213,7 +213,9 @@ pub fn UserPage() -> impl IntoView {
}
});
view! {
<div class="tl-header w-100 center mb-s ml-1" >view::user</div>
<div class="ml-1">
<div class="tl-header w-100 center mb-s" >view::user</div>
<div class="boxscroll" >
{move || match actor.get() {
None => view! { <p>loading...</p> }.into_view(),
Some(None) => view! { <p><code>error loading</code></p> }.into_view(),
@ -236,8 +238,12 @@ pub fn UserPage() -> impl IntoView {
<li><code>created</code>" "{x.published().map(|x| x.to_rfc3339())}</li>
</ul>
</div>
<hr />
<TimelineFeed tl=Timeline::new(format!("{}/outbox/page", Uri::api("users", x.id().unwrap_or_default()))) />
}.into_view(),
}}
</div>
</div>
}
}
@ -258,14 +264,16 @@ pub fn ObjectPage() -> impl IntoView {
}
});
view! {
<div class="tl-header w-100 center mb-s ml-1" >view::object</div>
<div class="ma-2" >
<div class="ml-1">
<div class="tl-header w-100 center mb-s" >view::object</div>
<div class="boxscroll ma-2" >
{move || match object.get() {
Some(Some(o)) => view!{ <Object object=o /> }.into_view(),
Some(None) => view! { <p><code>loading failed</code></p> }.into_view(),
None => view! { <p> loading ... </p> }.into_view(),
}}
</div>
</div>
}
}
@ -365,12 +373,21 @@ pub fn About() -> impl IntoView {
struct OmgReqwestErrorIsNotClonable(String);
#[component]
pub fn TimelineFeed(name: &'static str, tl: Timeline) -> impl IntoView {
let auth = use_context::<Signal<Option<Auth>>>().expect("missing auth context");
pub fn TimelinePage(name: &'static str, tl: Timeline) -> impl IntoView {
view! {
<div class="ml-1">
<div class="tl-header w-100 center mb-s" >{name}</div>
<div class="boxscroll mt-s mb-s" >
<TimelineFeed tl=tl />
</div>
</div>
}
}
#[component]
pub fn TimelineFeed(tl: Timeline) -> impl IntoView {
let auth = use_context::<Signal<Option<Auth>>>().expect("missing auth context");
view! {
<For
each=move || tl.feed.get()
key=|k| k.to_string()
@ -401,7 +418,5 @@ pub fn TimelineFeed(name: &'static str, tl: Timeline) -> impl IntoView {
}
>more</button>
</div>
</div>
</div>
}
}

View file

@ -4,7 +4,7 @@ use leptos_router::*;
use leptos_use::{use_cookie, utils::JsonCodec};
use upub_web::{
URL_BASE, context::Timeline, About, Auth, LoginBox, MaybeToken, ObjectPage, PostBox,
TimelineFeed, TimelineNavigation, UserPage
TimelinePage, TimelineNavigation, UserPage
};
fn main() {
@ -72,8 +72,8 @@ fn main() {
<Routes>
<Route path="/web" view=About />
<Route path="/web/home" view=move || view! { <TimelineFeed name="home" tl=home_tl /> } />
<Route path="/web/server" view=move || view! { <TimelineFeed name="server" tl=server_tl /> } />
<Route path="/web/home" view=move || view! { <TimelinePage name="home" tl=home_tl /> } />
<Route path="/web/server" view=move || view! { <TimelinePage name="server" tl=server_tl /> } />
<Route path="/web/users/:id" view=UserPage />
<Route path="/web/objects/:id" view=ObjectPage />