fix(web): only refresh if logged in

This commit is contained in:
əlemi 2024-05-27 07:37:46 +02:00
parent dfbac324f5
commit 399fdecee7
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -12,10 +12,11 @@ pub fn App() -> impl IntoView {
let (userid, set_userid) = use_cookie::<String, FromToStringCodec>("user_id");
let (config, set_config, _) = use_local_storage::<crate::Config, JsonCodec>("config");
if let Some(tok) = token.get_untracked() {
spawn_local(async move {
match reqwest::Client::new()
.request(Method::PATCH, format!("{URL_BASE}/auth"))
.json(&serde_json::json!({"token": token.get().unwrap_or_default()}))
.json(&serde_json::json!({"token": tok}))
.send()
.await
{
@ -31,7 +32,8 @@ pub fn App() -> impl IntoView {
}
}
}
});
})
};
let auth = Auth { token, userid };
provide_context(auth);