1
0
Fork 0
forked from alemi/upub

fix(web): user page responds to url again

This commit is contained in:
əlemi 2024-05-29 22:14:15 +02:00
parent e3831650ca
commit 7019671f93
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 16 additions and 15 deletions

View file

@ -34,8 +34,7 @@ pub fn App() -> impl IntoView {
let (menu, set_menu) = create_signal(screen_width <= 786);
let (advanced, set_advanced) = create_signal(false);
let auth_present = auth.token.get_untracked().is_some(); // skip helper to use get_untracked
let title_target = move || if auth_present { "/web/home" } else { "/web/server" };
let title_target = move || if auth.present() { "/web/home" } else { "/web/server" };
if let Some(tok) = token.get_untracked() {
spawn_local(async move {
@ -61,7 +60,7 @@ pub fn App() -> impl IntoView {
server_tl.more(auth);
local_tl.more(auth);
if auth_present { home_tl.more(auth) };
if auth.token.get_untracked().is_some() { home_tl.more(auth) };
})
} else {
server_tl.more(auth);

View file

@ -28,20 +28,22 @@ pub fn UserPage(tl: Timeline) -> impl IntoView {
.cloned()
.unwrap_or_default();
let uid = uriproxy::uri(URL_BASE, uriproxy::UriClass::Actor, &id);
let _uid = uid.clone();
let actor = create_local_resource(move || _uid.clone(), move |id| {
async move {
match CACHE.get(&Uri::full(U::Actor, &id)) {
Some(x) => Some(x.clone()),
None => {
let user : serde_json::Value = Http::fetch(&Uri::api(U::Actor, &id, true), auth).await.ok()?;
let user = Arc::new(user);
CACHE.put(Uri::full(U::Actor, &id), user.clone());
Some(user)
},
let actor = create_local_resource(
move || params.get().get("id").cloned().unwrap_or_default(),
move |id| {
async move {
match CACHE.get(&Uri::full(U::Actor, &id)) {
Some(x) => Some(x.clone()),
None => {
let user : serde_json::Value = Http::fetch(&Uri::api(U::Actor, &id, true), auth).await.ok()?;
let user = Arc::new(user);
CACHE.put(Uri::full(U::Actor, &id), user.clone());
Some(user)
},
}
}
}
});
);
view! {
<div>
<Breadcrumb back=true >