mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 16:51:57 +00:00
Add catalog settings management in HomeScreen for improved catalog loading
This commit is contained in:
parent
60cfdaf049
commit
5f8bb8948d
1 changed files with 76 additions and 61 deletions
|
|
@ -62,6 +62,10 @@ import homeStyles, { sharedStyles } from '../styles/homeStyles';
|
|||
import { useTheme } from '../contexts/ThemeContext';
|
||||
import type { Theme } from '../contexts/ThemeContext';
|
||||
import * as ScreenOrientation from 'expo-screen-orientation';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
|
||||
// Constants
|
||||
const CATALOG_SETTINGS_KEY = 'catalog_settings';
|
||||
|
||||
// Define interfaces for our data
|
||||
interface Category {
|
||||
|
|
@ -415,6 +419,10 @@ const HomeScreen = () => {
|
|||
try {
|
||||
const addons = await catalogService.getAllAddons();
|
||||
|
||||
// Load catalog settings to check which catalogs are enabled
|
||||
const catalogSettingsJson = await AsyncStorage.getItem(CATALOG_SETTINGS_KEY);
|
||||
const catalogSettings = catalogSettingsJson ? JSON.parse(catalogSettingsJson) : {};
|
||||
|
||||
// Create placeholder array with proper order and track indices
|
||||
const catalogPlaceholders: (CatalogContent | null)[] = [];
|
||||
const catalogPromises: Promise<void>[] = [];
|
||||
|
|
@ -423,6 +431,12 @@ const HomeScreen = () => {
|
|||
for (const addon of addons) {
|
||||
if (addon.catalogs) {
|
||||
for (const catalog of addon.catalogs) {
|
||||
// Check if this catalog is enabled (default to true if no setting exists)
|
||||
const settingKey = `${addon.id}:${catalog.type}:${catalog.id}`;
|
||||
const isEnabled = catalogSettings[settingKey] ?? true;
|
||||
|
||||
// Only load enabled catalogs
|
||||
if (isEnabled) {
|
||||
const currentIndex = catalogIndex;
|
||||
catalogPlaceholders.push(null); // Reserve position
|
||||
|
||||
|
|
@ -490,9 +504,10 @@ const HomeScreen = () => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
totalCatalogsRef.current = catalogIndex;
|
||||
console.log(`[HomeScreen] Starting to load ${catalogIndex} catalogs progressively...`);
|
||||
console.log(`[HomeScreen] Starting to load ${catalogIndex} enabled catalogs progressively...`);
|
||||
|
||||
// Initialize catalogs array with proper length
|
||||
setCatalogs(new Array(catalogIndex).fill(null));
|
||||
|
|
|
|||
Loading…
Reference in a new issue