Compare commits

..

1 Commits
3013 ... 3014

Author SHA1 Message Date
Greg Johnston
faf0cb3378 fix: correct Owner restoration in FlatRoutes (closes #3014) 2024-09-24 19:35:19 -04:00
3 changed files with 8 additions and 43 deletions

View File

@@ -24,35 +24,7 @@ use reactive_graph::{
prelude::*,
signal::{ArcRwSignal, RwSignal},
};
use std::{
future::{pending, IntoFuture},
ops::Deref,
panic::Location,
sync::atomic::{AtomicBool, Ordering},
};
static IS_SUPPRESSING_RESOURCE_LOAD: AtomicBool = AtomicBool::new(false);
pub struct SuppressResourceLoad;
impl SuppressResourceLoad {
pub fn new() -> Self {
IS_SUPPRESSING_RESOURCE_LOAD.store(true, Ordering::Relaxed);
Self
}
}
impl Default for SuppressResourceLoad {
fn default() -> Self {
Self::new()
}
}
impl Drop for SuppressResourceLoad {
fn drop(&mut self) {
IS_SUPPRESSING_RESOURCE_LOAD.store(false, Ordering::Relaxed);
}
}
use std::{future::IntoFuture, ops::Deref, panic::Location};
pub struct ArcResource<T, Ser = JsonSerdeCodec> {
ser: PhantomData<Ser>,
@@ -144,14 +116,7 @@ where
let source = source.clone();
move || {
let (_, source) = source.get();
let fut = fetcher(source);
async move {
if IS_SUPPRESSING_RESOURCE_LOAD.load(Ordering::Relaxed) {
pending().await
} else {
fut.await
}
}
fetcher(source)
}
};

View File

@@ -43,7 +43,7 @@ where
Fal: Render + 'static,
{
#[allow(clippy::type_complexity)]
view: <EitherOf3<(), Fal, <Defs::Match as MatchInterface>::View> as Render>::State,
view: <EitherOf3<(), Fal, OwnedView<<Defs::Match as MatchInterface>::View>> as Render>::State,
id: Option<RouteMatchId>,
owner: Owner,
params: ArcRwSignal<ParamsMap>,
@@ -147,7 +147,7 @@ where
provide_context(params_memo);
provide_context(url);
provide_context(Matched(ArcMemo::from(matched)));
view.choose().await
OwnedView::new(view.choose().await)
}
})
}));
@@ -292,7 +292,7 @@ where
provide_context(Matched(ArcMemo::from(
new_matched,
)));
let view =
let view = OwnedView::new(
if let Some(set_is_routing) = set_is_routing {
set_is_routing.set(true);
let value =
@@ -302,7 +302,8 @@ where
value
} else {
view.choose().await
};
},
);
// only update the route if it's still the current path
// i.e., if we've navigated away before this has loaded, do nothing
@@ -572,7 +573,7 @@ where
provide_context(params_memo);
provide_context(url);
provide_context(Matched(ArcMemo::from(matched)));
view.choose().await
OwnedView::new(view.choose().await)
}
})
}));

View File

@@ -224,7 +224,6 @@ impl RouteList {
where
T: RenderHtml,
{
let _resource_guard = leptos::server::SuppressResourceLoad::new();
Self::IS_GENERATING.set(true);
// run the app once, but throw away the HTML
// the router won't actually route, but will fill the listing