From cd4d124e22f05d29be539499b84c6cf65c6ea634 Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Wed, 23 Jul 2025 09:50:37 +0200 Subject: [PATCH] u --- src/components/Content.js | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/components/Content.js b/src/components/Content.js index d0e3090..c785d14 100644 --- a/src/components/Content.js +++ b/src/components/Content.js @@ -259,19 +259,15 @@ class Content extends Component { fetchCategoryData(categoryId) { - // Simply check if we have any category tree data in window.productCache - const hasCategoryTree = window.productCache && - Object.keys(window.productCache).some(key => - key.startsWith("categoryTree_209") && - window.productCache[key] && - window.productCache[key].categoryTree); + // Direct check for the specific cache key mentioned in the requirement + const hasCategoryTree = window.productCache && window.productCache["categoryTree_209"]; // Check for specific category data in cache const cachedData = getCachedCategoryData(categoryId); // If we have the category tree data, use it and don't query socket.io if (hasCategoryTree) { - console.log("Found category tree in cache"); + console.log("Found categoryTree_209 in cache"); if (cachedData) { console.log("Using cached category data for", categoryId); @@ -414,22 +410,12 @@ class Content extends Component { // Helper function to get category name from tree getCategoryNameFromTree = (categoryId) => { - if (!window.productCache) { + if (!window.productCache || !window.productCache["categoryTree_209"] || + !window.productCache["categoryTree_209"].categoryTree) { return null; } - // Find the first available category tree - const categoryTreeKey = Object.keys(window.productCache).find(key => - key.startsWith("categoryTree_209") && - window.productCache[key] && - window.productCache[key].categoryTree - ); - - if (!categoryTreeKey) { - return null; - } - - const categoryTree = window.productCache[categoryTreeKey].categoryTree; + const categoryTree = window.productCache["categoryTree_209"].categoryTree; // If categoryId is a string (SEO name), find by seoName, otherwise by ID const category = typeof categoryId === 'string'