use leptos::{leptos_dom::logging::console_error, *}; use leptos_router::*; use leptos_use::{use_cookie, utils::FromToStringCodec}; use upub_web::{ URL_BASE, context::Timeline, About, LoginBox, MaybeToken, ObjectPage, PostBox, TimelinePage, Navigator, UserPage }; fn main() { _ = console_log::init_with_level(log::Level::Info); console_error_panic_hook::set_once(); let (token, set_token) = use_cookie::("token"); let (username, set_username) = use_cookie::("username"); provide_context(token); 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(token).await { console_error(&format!("error populating timeline: {e}")); } }); if token.get().is_some() { spawn_local(async move { if let Err(e) = home_tl.more(token).await { console_error(&format!("error populating timeline: {e}")); } }); } mount_to_body( move || 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! { } } /> } /> } /> } />
} }}
} ); }