From a16b20f6faf988374b38ba2cef5ef4ffe10b917a Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 3 May 2024 03:55:26 +0200 Subject: [PATCH] chore(web): get_untracked when needed --- web/src/app.rs | 12 ++++++++---- web/src/components/timeline.rs | 4 ++-- web/src/lib.rs | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/web/src/app.rs b/web/src/app.rs index d09bbfa6..9e7845ef 100644 --- a/web/src/app.rs +++ b/web/src/app.rs @@ -17,9 +17,12 @@ pub fn App() -> impl IntoView { let auth = Auth { token, userid }; provide_context(auth); - let home_tl = Timeline::new(format!("{URL_BASE}/users/{}/inbox/page", auth.username())); + let username = auth.userid.get_untracked() + .map(|x| x.split('/').last().unwrap_or_default().to_string()) + .unwrap_or_default(); + let home_tl = Timeline::new(format!("{URL_BASE}/users/{username}/inbox/page")); let server_tl = Timeline::new(format!("{URL_BASE}/inbox/page")); - let user_tl = Timeline::new(format!("{URL_BASE}/users/{}/outbox/page", auth.username())); + let user_tl = Timeline::new(format!("{URL_BASE}/users/{username}/outbox/page")); let context_tl = Timeline::new(format!("{URL_BASE}/outbox/page")); let reply_controls = ReplyControls::default(); @@ -36,7 +39,8 @@ pub fn App() -> impl IntoView { } }); - if auth.present() { + let auth_present = auth.token.get_untracked().is_some(); // skip helper to use get_untracked + if auth_present { spawn_local(async move { if let Err(e) = home_tl.more(auth).await { tracing::error!("error populating timeline: {e}"); @@ -44,7 +48,7 @@ pub fn App() -> impl IntoView { }); } - let title_target = if auth.present() { "/web/home" } else { "/web/server" }; + let title_target = if auth_present { "/web/home" } else { "/web/server" }; view! {