use leptos::*; use leptos_router::*; use crate::prelude::*; use leptos_use::{use_cookie, utils::FromToStringCodec}; #[component] pub fn App() -> impl IntoView { let (auth, set_auth) = use_cookie::("token"); let (username, set_username) = use_cookie::("username"); provide_context(auth); let home_tl = Timeline::new(format!("{URL_BASE}/users/{}/inbox/page", username.get().unwrap_or_default())); let server_tl = Timeline::new(format!("{URL_BASE}/inbox/page")); let screen_width = window().screen().map(|x| x.avail_width().unwrap_or_default()).unwrap_or_default(); let (menu, set_menu) = create_signal(screen_width <= 786); spawn_local(async move { if let Err(e) = server_tl.more(auth).await { tracing::error!("error populating timeline: {e}"); } }); if auth.get().is_some() { spawn_local(async move { if let Err(e) = home_tl.more(auth).await { tracing::error!("error populating timeline: {e}"); } }); } let title_target = if auth.present() { "/web/home" } else { "/web/server" }; view! {


nothing to see here!

}.into_view() > // TODO this is kind of ugly: the whole router gets rebuilt every time we log in/out // in a sense it's what we want: refreshing the home tl is main purpose, but also // server tl may contain stuff we can no longer see, or otherwise we may now be // entitled to see new posts. so while being ugly it's techically correct ig? {move || { view! {
} } else { view! { } } /> } /> } /> } />
} }}
} }