Skip to content

Commit e3b49e1

Browse files
committed
fix(capsules): fixed initial widget caching with i18n
1 parent e9c5f4d commit e3b49e1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/perseus/src/reactor/render_mode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub(crate) enum RenderMode<G: Html> {
5757
///
5858
/// Importantly, widget states are *not* fallible at build-time!
5959
/// Any errors will be propagated to terminate the build.
60-
widget_states: Rc<RefCell<HashMap<String, (String, Value)>>>,
60+
widget_states: Rc<RefCell<HashMap<PathMaybeWithLocale, (String, Value)>>>,
6161
/// A list of widget paths that are either nonexistent, or able to be
6262
/// incrementally generated. The build process should parse these and
6363
/// try to build them all (failing entirely on any that actually don't

packages/perseus/src/template/widget_component.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -315,17 +315,19 @@ impl<G: Html, P: Clone + 'static> Capsule<G, P> {
315315
}
316316
};
317317

318+
let localized_path = PathMaybeWithLocale::new(&path, &locale);
319+
318320
// Add this to the list of widget states so they can be written for later
319321
// use
320322
widget_states.borrow_mut().insert(
321-
path.to_string(),
323+
localized_path.clone(),
322324
(capsule_name.to_string(), state.state.clone()),
323325
);
324326

325327
// SAFETY: We asserted above that `G == H`.
326328
let self_copy: &Capsule<H, P> = unsafe { std::mem::transmute_copy(&self) };
327329
match self_copy.render_widget_for_template_server(
328-
PathMaybeWithLocale::new(&path, &locale),
330+
localized_path,
329331
state,
330332
props,
331333
cx,

0 commit comments

Comments
 (0)