refactor: enhance logging and cache checks in SharedCarousel and CategoryList components to improve data fetching clarity and performance

This commit is contained in:
sebseb7
2025-07-23 10:22:19 +02:00
parent 226ca3e834
commit 95f303bc68
2 changed files with 5 additions and 0 deletions

View File

@@ -85,12 +85,14 @@ const SharedCarousel = () => {
// Use cache if available
if (categoryTree) {
console.log('SharedCarousel: Using cached category tree');
setRootCategories(processCategoryTree(categoryTree));
return;
}
// Only fetch if needed
if (rootCategories.length === 0 && typeof window !== "undefined") {
console.log('SharedCarousel: Cache not found, fetching from socket');
window.socketManager.emit("categoryList", { categoryId: 209, language: currentLanguage, requestTranslation: true }, (response) => {
if (response && response.success) {
// Use translated data if available, otherwise fall back to original