diff --git a/cart/app.py b/cart/app.py index dad13cd..3f041b2 100644 --- a/cart/app.py +++ b/cart/app.py @@ -52,17 +52,32 @@ async def cart_context() -> dict: """ from shared.infrastructure.context import base_context from shared.services.navigation import get_navigation_tree - from shared.infrastructure.fragments import fetch_fragment + from shared.infrastructure.cart_identity import current_cart_identity + from shared.infrastructure.fragments import fetch_fragments ctx = await base_context() - ctx["nav_tree_html"] = await fetch_fragment( - "blog", "nav-tree", - params={"app_name": "cart", "path": request.path}, - ) # Fallback for _nav.html when nav-tree fragment fetch fails ctx["menu_items"] = await get_navigation_tree(g.s) + # Pre-fetch cross-app HTML fragments concurrently + user = getattr(g, "user", None) + ident = current_cart_identity() + cart_params = {} + if ident["user_id"] is not None: + cart_params["user_id"] = ident["user_id"] + if ident["session_id"] is not None: + cart_params["session_id"] = ident["session_id"] + + cart_mini_html, auth_menu_html, nav_tree_html = await fetch_fragments([ + ("cart", "cart-mini", cart_params or None), + ("account", "auth-menu", {"email": user.email} if user else None), + ("blog", "nav-tree", {"app_name": "cart", "path": request.path}), + ]) + ctx["cart_mini_html"] = cart_mini_html + ctx["auth_menu_html"] = auth_menu_html + ctx["nav_tree_html"] = nav_tree_html + # Cart app owns cart data — use g.cart from _load_cart all_cart = getattr(g, "cart", None) or [] all_cal = await get_calendar_cart_entries(g.s) diff --git a/cart/templates/_types/product/_cart.html b/cart/templates/_types/product/_cart.html index 2c68284..d8ce3e1 100644 --- a/cart/templates/_types/product/_cart.html +++ b/cart/templates/_types/product/_cart.html @@ -130,7 +130,7 @@ class="w-24 h-24 sm:w-32 sm:h-28 rounded-xl border border-dashed border-stone-300 flex items-center justify-center text-xs text-stone-400" > No image - 'market', 'product', p.slug + {% endif %} @@ -139,7 +139,7 @@