forked from alemi/upub
feat(web): per-user timeline, proper scrollboxes
This commit is contained in:
parent
5de3e6622f
commit
964b45e50b
2 changed files with 82 additions and 67 deletions
|
@ -213,7 +213,9 @@ pub fn UserPage() -> impl IntoView {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view! {
|
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() {
|
{move || match actor.get() {
|
||||||
None => view! { <p>loading...</p> }.into_view(),
|
None => view! { <p>loading...</p> }.into_view(),
|
||||||
Some(None) => view! { <p><code>error loading</code></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>
|
<li><code>created</code>" "{x.published().map(|x| x.to_rfc3339())}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<hr />
|
||||||
|
<TimelineFeed tl=Timeline::new(format!("{}/outbox/page", Uri::api("users", x.id().unwrap_or_default()))) />
|
||||||
}.into_view(),
|
}.into_view(),
|
||||||
}}
|
}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,14 +264,16 @@ pub fn ObjectPage() -> impl IntoView {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view! {
|
view! {
|
||||||
<div class="tl-header w-100 center mb-s ml-1" >view::object</div>
|
<div class="ml-1">
|
||||||
<div class="ma-2" >
|
<div class="tl-header w-100 center mb-s" >view::object</div>
|
||||||
|
<div class="boxscroll ma-2" >
|
||||||
{move || match object.get() {
|
{move || match object.get() {
|
||||||
Some(Some(o)) => view!{ <Object object=o /> }.into_view(),
|
Some(Some(o)) => view!{ <Object object=o /> }.into_view(),
|
||||||
Some(None) => view! { <p><code>loading failed</code></p> }.into_view(),
|
Some(None) => view! { <p><code>loading failed</code></p> }.into_view(),
|
||||||
None => view! { <p> loading ... </p> }.into_view(),
|
None => view! { <p> loading ... </p> }.into_view(),
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,12 +373,21 @@ pub fn About() -> impl IntoView {
|
||||||
struct OmgReqwestErrorIsNotClonable(String);
|
struct OmgReqwestErrorIsNotClonable(String);
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn TimelineFeed(name: &'static str, tl: Timeline) -> impl IntoView {
|
pub fn TimelinePage(name: &'static str, tl: Timeline) -> impl IntoView {
|
||||||
let auth = use_context::<Signal<Option<Auth>>>().expect("missing auth context");
|
|
||||||
view! {
|
view! {
|
||||||
<div class="ml-1">
|
<div class="ml-1">
|
||||||
<div class="tl-header w-100 center mb-s" >{name}</div>
|
<div class="tl-header w-100 center mb-s" >{name}</div>
|
||||||
<div class="boxscroll mt-s mb-s" >
|
<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
|
<For
|
||||||
each=move || tl.feed.get()
|
each=move || tl.feed.get()
|
||||||
key=|k| k.to_string()
|
key=|k| k.to_string()
|
||||||
|
@ -401,7 +418,5 @@ pub fn TimelineFeed(name: &'static str, tl: Timeline) -> impl IntoView {
|
||||||
}
|
}
|
||||||
>more</button>
|
>more</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use leptos_router::*;
|
||||||
use leptos_use::{use_cookie, utils::JsonCodec};
|
use leptos_use::{use_cookie, utils::JsonCodec};
|
||||||
use upub_web::{
|
use upub_web::{
|
||||||
URL_BASE, context::Timeline, About, Auth, LoginBox, MaybeToken, ObjectPage, PostBox,
|
URL_BASE, context::Timeline, About, Auth, LoginBox, MaybeToken, ObjectPage, PostBox,
|
||||||
TimelineFeed, TimelineNavigation, UserPage
|
TimelinePage, TimelineNavigation, UserPage
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -72,8 +72,8 @@ fn main() {
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/web" view=About />
|
<Route path="/web" view=About />
|
||||||
|
|
||||||
<Route path="/web/home" view=move || view! { <TimelineFeed name="home" tl=home_tl /> } />
|
<Route path="/web/home" view=move || view! { <TimelinePage name="home" tl=home_tl /> } />
|
||||||
<Route path="/web/server" view=move || view! { <TimelineFeed name="server" tl=server_tl /> } />
|
<Route path="/web/server" view=move || view! { <TimelinePage name="server" tl=server_tl /> } />
|
||||||
|
|
||||||
<Route path="/web/users/:id" view=UserPage />
|
<Route path="/web/users/:id" view=UserPage />
|
||||||
<Route path="/web/objects/:id" view=ObjectPage />
|
<Route path="/web/objects/:id" view=ObjectPage />
|
||||||
|
|
Loading…
Reference in a new issue