Revert "improved documentation and refactored naming to be more self-explanatory"
This reverts commit adfbb6c380.
This commit is contained in:
1 parent
adfbb6c380
commit
906c466e78
91 files changed
+1553
-1663
No files matched your search
@@ -77,18 +77,17 @@ where
|
||||
self.routes.retain(|&lhs, _| lhs <= last_visited);
|
||||
}
|
||||
};
|
||||
let state =
|
||||
match state {
|
||||
Some(state) => {
|
||||
self.current_index = state.index;
|
||||
state
|
||||
}
|
||||
None => {
|
||||
let index = depth - 1;
|
||||
self.current_index = index;
|
||||
State { index }
|
||||
}
|
||||
};
|
||||
let state = match state {
|
||||
Some(state) => {
|
||||
self.current_index = state.index;
|
||||
state
|
||||
}
|
||||
None => {
|
||||
let index = depth - 1;
|
||||
self.current_index = index;
|
||||
State { index }
|
||||
}
|
||||
};
|
||||
self.routes.insert(state.index, route);
|
||||
state
|
||||
}
|
||||
|
||||
@@ -302,16 +302,15 @@ where
|
||||
let s = self.listener_animation_frame.clone();
|
||||
let d = self.do_scroll_restoration;
|
||||
|
||||
self.listener_navigation =
|
||||
Some(EventListener::new(&self.window, "popstate", move |_| {
|
||||
(*callback)();
|
||||
if d {
|
||||
let mut s = s.lock().expect("unpoisoned scroll mutex");
|
||||
if let Some(current_state) = get_current::<WebHistoryState<R>>(&h) {
|
||||
*s = Some(current_state.scroll.scroll_to(w.clone()));
|
||||
}
|
||||
self.listener_navigation = Some(EventListener::new(&self.window, "popstate", move |_| {
|
||||
(*callback)();
|
||||
if d {
|
||||
let mut s = s.lock().expect("unpoisoned scroll mutex");
|
||||
if let Some(current_state) = get_current::<WebHistoryState<R>>(&h) {
|
||||
*s = Some(current_state.scroll.scroll_to(w.clone()));
|
||||
}
|
||||
}));
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,15 +377,14 @@ where
|
||||
let s = self.listener_animation_frame.clone();
|
||||
let d = self.do_scroll_restoration;
|
||||
|
||||
self.listener_navigation =
|
||||
Some(EventListener::new(&self.window, "popstate", move |_| {
|
||||
(*callback)();
|
||||
if d {
|
||||
let mut s = s.lock().expect("unpoisoned scroll mutex");
|
||||
if let Some([x, y]) = get_current(&h) {
|
||||
*s = Some(ScrollPosition { x, y }.scroll_to(w.clone()));
|
||||
}
|
||||
self.listener_navigation = Some(EventListener::new(&self.window, "popstate", move |_| {
|
||||
(*callback)();
|
||||
if d {
|
||||
let mut s = s.lock().expect("unpoisoned scroll mutex");
|
||||
if let Some([x, y]) = get_current(&h) {
|
||||
*s = Some(ScrollPosition { x, y }.scroll_to(w.clone()));
|
||||
}
|
||||
}));
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -114,9 +114,11 @@ impl<R: Routable> FromStr for NavigationTarget<R> {
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match Url::parse(s) {
|
||||
Ok(_) => Ok(Self::External(s.to_string())),
|
||||
Err(ParseError::RelativeUrlWithoutBase) => Ok(Self::Internal(
|
||||
R::from_str(s).map_err(|e| NavigationTargetParseError::InvalidInternalURL(e))?,
|
||||
)),
|
||||
Err(ParseError::RelativeUrlWithoutBase) => {
|
||||
Ok(Self::Internal(R::from_str(s).map_err(|e| {
|
||||
NavigationTargetParseError::InvalidInternalURL(e)
|
||||
})?))
|
||||
}
|
||||
Err(e) => Err(NavigationTargetParseError::InvalidUrl(e)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,12 +134,11 @@ impl<I: std::iter::FromIterator<String>> FromRouteSegments for I {
|
||||
|
||||
/// A flattened version of [`Routable::SITE_MAP`].
|
||||
/// This essentially represents a `Vec<Vec<SegmentType>>`, which you can collect it into.
|
||||
type SiteMapFlattened<'a> =
|
||||
FlatMap<
|
||||
Iter<'a, SiteMapSegment>,
|
||||
Vec<Vec<SegmentType>>,
|
||||
fn(&SiteMapSegment) -> Vec<Vec<SegmentType>>,
|
||||
>;
|
||||
type SiteMapFlattened<'a> = FlatMap<
|
||||
Iter<'a, SiteMapSegment>,
|
||||
Vec<Vec<SegmentType>>,
|
||||
fn(&SiteMapSegment) -> Vec<Vec<SegmentType>>,
|
||||
>;
|
||||
|
||||
fn seg_strs_to_route<T>(segs_maybe: &Option<Vec<&str>>) -> Option<T>
|
||||
where
|
||||
|
||||
@@ -11,15 +11,14 @@ use crate::prelude::*;
|
||||
/// - [`None`], when the current component isn't a descendant of a [`Link`] component.
|
||||
/// - Otherwise [`Some`].
|
||||
pub(crate) fn use_router_internal(cx: &ScopeState) -> &Option<RouterContext> {
|
||||
let inner =
|
||||
cx.use_hook(|| {
|
||||
let router = cx.consume_context::<RouterContext>()?;
|
||||
let inner = cx.use_hook(|| {
|
||||
let router = cx.consume_context::<RouterContext>()?;
|
||||
|
||||
let id = cx.scope_id();
|
||||
router.subscribe(id);
|
||||
let id = cx.scope_id();
|
||||
router.subscribe(id);
|
||||
|
||||
Some(Subscription { router, id })
|
||||
});
|
||||
Some(Subscription { router, id })
|
||||
});
|
||||
cx.use_hook(|| inner.as_ref().map(|s| s.router.clone()))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user