app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit 6d6820114684944ad0fa336ec15cbec534aa2560
parent 00fa7bd1cf1805fc4ab451a3a1559d87f98336ec
Author: triesap <triesap@radroots.dev>
Date:   Tue, 20 Jan 2026 16:49:26 +0000

app: defer health checks after first paint

- add health check delay constant and helper

- schedule health checks with timeout future

- keep manual run checks behavior intact

- add unit test for delay helper

Diffstat:
Mapp/src/app.rs | 23++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/app/src/app.rs b/app/src/app.rs @@ -1,3 +1,4 @@ +use gloo_timers::future::TimeoutFuture; use leptos::prelude::*; use leptos::task::spawn_local; use leptos_router::components::{A, Route, Router, Routes}; @@ -99,6 +100,12 @@ fn spawn_health_checks( }); } +const APP_HEALTH_CHECK_DELAY_MS: u32 = 300; + +fn app_health_check_delay_ms() -> u32 { + APP_HEALTH_CHECK_DELAY_MS +} + #[component] fn HomePage() -> impl IntoView { let backends = RwSignal::new_local(None::<AppBackends>); @@ -184,7 +191,11 @@ fn HomePage() -> impl IntoView { return; }; health_autorun.set(true); - spawn_health_checks(config, health_report, health_running, active_key); + let delay_ms = app_health_check_delay_ms(); + spawn_local(async move { + TimeoutFuture::new(delay_ms).await; + spawn_health_checks(config, health_report, health_running, active_key); + }); }); let status_color = move || match init_state.get().stage { AppInitStage::Ready => "green", @@ -381,3 +392,13 @@ pub fn App() -> impl IntoView { </Router> } } + +#[cfg(test)] +mod tests { + use super::app_health_check_delay_ms; + + #[test] + fn health_check_delay_is_positive() { + assert!(app_health_check_delay_ms() > 0); + } +}