Refactor loading state logic in HomeScreen to improve data display handling. Update isLoading calculation to show full-screen loader only when no data is available, enhancing user experience during content loading.

This commit is contained in:
tapframe 2025-07-05 20:20:11 +05:30
parent 8481bb5609
commit e2403ecd71

View file

@ -249,11 +249,15 @@ const HomeScreen = () => {
}, []); }, []);
// Only count feature section as loading if it's enabled in settings // Only count feature section as loading if it's enabled in settings
// For catalogs, we show them progressively, so only show loading if no catalogs are loaded yet // Render the screen immediately and let placeholders/skeletons handle progressive loading
const isLoading = useMemo(() => const isLoading = useMemo(() => {
(showHeroSection ? featuredLoading : false) || (catalogsLoading && catalogs.length === 0), // Show a full-screen loader only if we literally have no data to display yet
[showHeroSection, featuredLoading, catalogsLoading, catalogs.length] const noHeroSection = !showHeroSection;
); const noFeaturedData = !featuredContent && featuredLoading;
const noCatalogsReady = catalogs.length === 0 && catalogsLoading;
return noHeroSection && noCatalogsReady && noFeaturedData;
}, [showHeroSection, featuredContent, featuredLoading, catalogsLoading, catalogs.length]);
// React to settings changes // React to settings changes
useEffect(() => { useEffect(() => {