Merge branch 'tapframe:main' into customConfirmation

This commit is contained in:
Christoffer Kronblad 2025-09-21 18:41:18 +02:00 committed by GitHub
commit 5d2fdbdde1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 136 additions and 94 deletions

View file

@ -1,7 +1,7 @@
import React, { useState, useRef, useEffect, useMemo, useCallback } from 'react'; import React, { useState, useRef, useEffect, useMemo, useCallback } from 'react';
import { View, TouchableOpacity, TouchableWithoutFeedback, Dimensions, Animated, ActivityIndicator, Platform, NativeModules, StatusBar, Text, Image, StyleSheet, Modal, AppState } from 'react-native'; import { View, TouchableOpacity, TouchableWithoutFeedback, Dimensions, Animated, ActivityIndicator, Platform, NativeModules, StatusBar, Text, Image, StyleSheet, Modal, AppState } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Video, { VideoRef, SelectedTrack, SelectedTrackType, BufferingStrategyType } from 'react-native-video'; import Video, { VideoRef, SelectedTrack, SelectedTrackType, BufferingStrategyType, ViewType } from 'react-native-video';
import { useNavigation, useRoute, RouteProp, useFocusEffect } from '@react-navigation/native'; import { useNavigation, useRoute, RouteProp, useFocusEffect } from '@react-navigation/native';
import { RootStackParamList } from '../../navigation/AppNavigator'; import { RootStackParamList } from '../../navigation/AppNavigator';
import { PinchGestureHandler, PanGestureHandler, TapGestureHandler, State, PinchGestureHandlerGestureEvent, PanGestureHandlerGestureEvent, TapGestureHandlerGestureEvent } from 'react-native-gesture-handler'; import { PinchGestureHandler, PanGestureHandler, TapGestureHandler, State, PinchGestureHandlerGestureEvent, PanGestureHandlerGestureEvent, TapGestureHandlerGestureEvent } from 'react-native-gesture-handler';
@ -1135,27 +1135,6 @@ const AndroidVideoPlayer: React.FC = () => {
}; };
}); });
setRnVideoAudioTracks(formattedAudioTracks); setRnVideoAudioTracks(formattedAudioTracks);
// Auto-select audio track if none is selected (similar to iOS behavior)
if (selectedAudioTrack?.type === SelectedTrackType.SYSTEM && formattedAudioTracks.length > 0) {
// Look for English track first
const englishTrack = formattedAudioTracks.find((track: {id: number, name: string, language?: string}) => {
const lang = (track.language || '').toLowerCase();
return lang === 'english' || lang === 'en' || lang === 'eng' ||
(track.name && track.name.toLowerCase().includes('english'));
});
const selectedTrack = englishTrack || formattedAudioTracks[0];
setSelectedAudioTrack({ type: SelectedTrackType.INDEX, value: selectedTrack.id });
if (DEBUG_MODE) {
if (englishTrack) {
logger.log(`[AndroidVideoPlayer] Auto-selected English audio track: ${selectedTrack.name} (ID: ${selectedTrack.id})`);
} else {
logger.log(`[AndroidVideoPlayer] No English track found, auto-selected first audio track: ${selectedTrack.name} (ID: ${selectedTrack.id})`);
}
}
}
if (DEBUG_MODE) { if (DEBUG_MODE) {
logger.log(`[AndroidVideoPlayer] Formatted audio tracks:`, formattedAudioTracks); logger.log(`[AndroidVideoPlayer] Formatted audio tracks:`, formattedAudioTracks);
@ -2770,8 +2749,8 @@ const AndroidVideoPlayer: React.FC = () => {
allowsExternalPlayback={false as any} allowsExternalPlayback={false as any}
preventsDisplaySleepDuringVideoPlayback={true as any} preventsDisplaySleepDuringVideoPlayback={true as any}
// ExoPlayer HLS optimization - let the player use optimal defaults // ExoPlayer HLS optimization - let the player use optimal defaults
// Use SurfaceView on Android to lower memory pressure with 4K/high-bitrate content // Use textureView on Android: allows 3D mapping but DRM not supported
useTextureView={Platform.OS === 'android' ? false : (undefined as any)} viewType={Platform.OS === 'android' ? ViewType.TEXTURE : undefined}
/> />
</TouchableOpacity> </TouchableOpacity>
</View> </View>

View file

@ -10,6 +10,7 @@ import {
RefreshControl, RefreshControl,
Dimensions, Dimensions,
Platform, Platform,
InteractionManager
} from 'react-native'; } from 'react-native';
import { FlashList } from '@shopify/flash-list'; import { FlashList } from '@shopify/flash-list';
import { RouteProp } from '@react-navigation/native'; import { RouteProp } from '@react-navigation/native';
@ -226,6 +227,7 @@ const CatalogScreen: React.FC<CatalogScreenProps> = ({ route, navigation }) => {
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [refreshing, setRefreshing] = useState(false); const [refreshing, setRefreshing] = useState(false);
const [error, setError] = useState<string | null>(null); const [error, setError] = useState<string | null>(null);
const [hasMore, setHasMore] = useState(false);
const [dataSource, setDataSource] = useState<DataSource>(DataSource.STREMIO_ADDONS); const [dataSource, setDataSource] = useState<DataSource>(DataSource.STREMIO_ADDONS);
const [actualCatalogName, setActualCatalogName] = useState<string | null>(null); const [actualCatalogName, setActualCatalogName] = useState<string | null>(null);
const [screenData, setScreenData] = useState(() => { const [screenData, setScreenData] = useState(() => {
@ -403,24 +405,30 @@ const CatalogScreen: React.FC<CatalogScreenProps> = ({ route, navigation }) => {
index === self.findIndex((t) => t.id === item.id) index === self.findIndex((t) => t.id === item.id)
); );
setItems(uniqueItems); InteractionManager.runAfterInteractions(() => {
setHasMore(false); // TMDB already returns a full set setItems(uniqueItems);
setLoading(false); setHasMore(false); // TMDB already returns a full set
setRefreshing(false); setLoading(false);
setRefreshing(false);
});
return; return;
} else { } else {
setError("No content found for the selected filters"); InteractionManager.runAfterInteractions(() => {
setItems([]); setError("No content found for the selected filters");
setLoading(false); setItems([]);
setRefreshing(false); setLoading(false);
setRefreshing(false);
});
return; return;
} }
} catch (error) { } catch (error) {
logger.error('Failed to get TMDB catalog:', error); logger.error('Failed to get TMDB catalog:', error);
setError('Failed to load content from TMDB'); InteractionManager.runAfterInteractions(() => {
setItems([]); setError('Failed to load content from TMDB');
setLoading(false); setItems([]);
setRefreshing(false); setLoading(false);
setRefreshing(false);
});
return; return;
} }
} }
@ -448,7 +456,9 @@ const CatalogScreen: React.FC<CatalogScreenProps> = ({ route, navigation }) => {
if (catalogItems.length > 0) { if (catalogItems.length > 0) {
foundItems = true; foundItems = true;
setItems(catalogItems); InteractionManager.runAfterInteractions(() => {
setItems(catalogItems);
});
} }
} else if (effectiveGenreFilter) { } else if (effectiveGenreFilter) {
// Get all addons that have catalogs of the specified type // Get all addons that have catalogs of the specified type
@ -527,19 +537,27 @@ const CatalogScreen: React.FC<CatalogScreenProps> = ({ route, navigation }) => {
if (uniqueItems.length > 0) { if (uniqueItems.length > 0) {
foundItems = true; foundItems = true;
setItems(uniqueItems); InteractionManager.runAfterInteractions(() => {
setItems(uniqueItems);
});
} }
} }
if (!foundItems) { if (!foundItems) {
setError("No content found for the selected filters"); InteractionManager.runAfterInteractions(() => {
setError("No content found for the selected filters");
});
} }
} catch (err) { } catch (err) {
setError(err instanceof Error ? err.message : 'Failed to load catalog items'); InteractionManager.runAfterInteractions(() => {
setError(err instanceof Error ? err.message : 'Failed to load catalog items');
});
logger.error('Failed to load catalog:', err); logger.error('Failed to load catalog:', err);
} finally { } finally {
setLoading(false); InteractionManager.runAfterInteractions(() => {
setRefreshing(false); setLoading(false);
setRefreshing(false);
});
} }
}, [addonId, type, id, genreFilter, dataSource]); }, [addonId, type, id, genreFilter, dataSource]);
@ -651,7 +669,7 @@ const CatalogScreen: React.FC<CatalogScreenProps> = ({ route, navigation }) => {
</Text> </Text>
<TouchableOpacity <TouchableOpacity
style={styles.button} style={styles.button}
onPress={() => loadItems(1)} onPress={() => loadItems(true)}
> >
<Text style={styles.buttonText}>Retry</Text> <Text style={styles.buttonText}>Retry</Text>
</TouchableOpacity> </TouchableOpacity>
@ -736,7 +754,6 @@ const CatalogScreen: React.FC<CatalogScreenProps> = ({ route, navigation }) => {
} }
contentContainerStyle={styles.list} contentContainerStyle={styles.list}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
estimatedItemSize={effectiveItemWidth * 1.5 + SPACING.lg}
/> />
) : renderEmptyState()} ) : renderEmptyState()}
</SafeAreaView> </SafeAreaView>

View file

@ -15,7 +15,8 @@ import {
Image, Image,
Modal, Modal,
Pressable, Pressable,
Alert Alert,
InteractionManager
} from 'react-native'; } from 'react-native';
import { FlashList } from '@shopify/flash-list'; import { FlashList } from '@shopify/flash-list';
import { useNavigation, useFocusEffect } from '@react-navigation/native'; import { useNavigation, useFocusEffect } from '@react-navigation/native';
@ -146,8 +147,10 @@ const HomeScreen = () => {
stremioService.getInstalledAddonsAsync() stremioService.getInstalledAddonsAsync()
]); ]);
// Set hasAddons state based on whether we have any addons // Set hasAddons state based on whether we have any addons - ensure on main thread
setHasAddons(addons.length > 0); InteractionManager.runAfterInteractions(() => {
setHasAddons(addons.length > 0);
});
const catalogSettings = catalogSettingsJson ? JSON.parse(catalogSettingsJson) : {}; const catalogSettings = catalogSettingsJson ? JSON.parse(catalogSettingsJson) : {};
@ -245,23 +248,28 @@ const HomeScreen = () => {
items items
}; };
// Update the catalog at its specific position // Update the catalog at its specific position - ensure on main thread
setCatalogs(prevCatalogs => { InteractionManager.runAfterInteractions(() => {
const newCatalogs = [...prevCatalogs]; setCatalogs(prevCatalogs => {
newCatalogs[currentIndex] = catalogContent; const newCatalogs = [...prevCatalogs];
return newCatalogs; newCatalogs[currentIndex] = catalogContent;
return newCatalogs;
});
}); });
} }
} catch (error) { } catch (error) {
if (__DEV__) console.error(`[HomeScreen] Failed to load ${catalog.name} from ${addon.name}:`, error); if (__DEV__) console.error(`[HomeScreen] Failed to load ${catalog.name} from ${addon.name}:`, error);
} finally { } finally {
setLoadedCatalogCount(prev => { // Update loading count - ensure on main thread
const next = prev + 1; InteractionManager.runAfterInteractions(() => {
// Exit loading screen as soon as first catalog finishes setLoadedCatalogCount(prev => {
if (prev === 0) { const next = prev + 1;
setCatalogsLoading(false); // Exit loading screen as soon as first catalog finishes
} if (prev === 0) {
return next; setCatalogsLoading(false);
}
return next;
});
}); });
} }
}; };
@ -275,14 +283,18 @@ const HomeScreen = () => {
totalCatalogsRef.current = catalogIndex; totalCatalogsRef.current = catalogIndex;
// Initialize catalogs array with proper length // Initialize catalogs array with proper length - ensure on main thread
setCatalogs(new Array(catalogIndex).fill(null)); InteractionManager.runAfterInteractions(() => {
setCatalogs(new Array(catalogIndex).fill(null));
});
// Start processing the catalog queue // Start processing the catalog queue
processCatalogQueue(); processCatalogQueue();
} catch (error) { } catch (error) {
if (__DEV__) console.error('[HomeScreen] Error in progressive catalog loading:', error); if (__DEV__) console.error('[HomeScreen] Error in progressive catalog loading:', error);
setCatalogsLoading(false); InteractionManager.runAfterInteractions(() => {
setCatalogsLoading(false);
});
} }
}, []); }, []);

View file

@ -80,29 +80,38 @@ const detectMkvViaHead = async (url: string, headers?: Record<string, string>) =
}; };
// Animated Components // Animated Components
const AnimatedImage = memo(({ const AnimatedImage = memo(({
source, source,
style, style,
contentFit, contentFit,
onLoad onLoad
}: { }: {
source: { uri: string } | undefined; source: { uri: string } | undefined;
style: any; style: any;
contentFit: any; contentFit: any;
onLoad?: () => void; onLoad?: () => void;
}) => { }) => {
const opacity = useSharedValue(0); const opacity = useSharedValue(0);
const animatedStyle = useAnimatedStyle(() => ({ const animatedStyle = useAnimatedStyle(() => ({
opacity: opacity.value, opacity: opacity.value,
})); }));
useEffect(() => { useEffect(() => {
if (source?.uri) { if (source?.uri) {
opacity.value = withTiming(1, { duration: 300 }); opacity.value = withTiming(1, { duration: 300 });
} else {
opacity.value = 0;
} }
}, [source?.uri]); }, [source?.uri]);
// Cleanup on unmount
useEffect(() => {
return () => {
opacity.value = 0;
};
}, []);
return ( return (
<Animated.View style={[style, animatedStyle]}> <Animated.View style={[style, animatedStyle]}>
<Image <Image
@ -115,30 +124,38 @@ const AnimatedImage = memo(({
); );
}); });
const AnimatedText = memo(({ const AnimatedText = memo(({
children, children,
style, style,
delay = 0, delay = 0,
numberOfLines numberOfLines
}: { }: {
children: React.ReactNode; children: React.ReactNode;
style: any; style: any;
delay?: number; delay?: number;
numberOfLines?: number; numberOfLines?: number;
}) => { }) => {
const opacity = useSharedValue(0); const opacity = useSharedValue(0);
const translateY = useSharedValue(20); const translateY = useSharedValue(20);
const animatedStyle = useAnimatedStyle(() => ({ const animatedStyle = useAnimatedStyle(() => ({
opacity: opacity.value, opacity: opacity.value,
transform: [{ translateY: translateY.value }], transform: [{ translateY: translateY.value }],
})); }));
useEffect(() => { useEffect(() => {
opacity.value = withDelay(delay, withTiming(1, { duration: 250 })); opacity.value = withDelay(delay, withTiming(1, { duration: 250 }));
translateY.value = withDelay(delay, withTiming(0, { duration: 250 })); translateY.value = withDelay(delay, withTiming(0, { duration: 250 }));
}, [delay]);
// Cleanup on unmount
useEffect(() => {
return () => {
opacity.value = 0;
translateY.value = 20;
};
}, []); }, []);
return ( return (
<Animated.Text style={[style, animatedStyle]} numberOfLines={numberOfLines}> <Animated.Text style={[style, animatedStyle]} numberOfLines={numberOfLines}>
{children} {children}
@ -146,28 +163,36 @@ const AnimatedText = memo(({
); );
}); });
const AnimatedView = memo(({ const AnimatedView = memo(({
children, children,
style, style,
delay = 0 delay = 0
}: { }: {
children: React.ReactNode; children: React.ReactNode;
style?: any; style?: any;
delay?: number; delay?: number;
}) => { }) => {
const opacity = useSharedValue(0); const opacity = useSharedValue(0);
const translateY = useSharedValue(20); const translateY = useSharedValue(20);
const animatedStyle = useAnimatedStyle(() => ({ const animatedStyle = useAnimatedStyle(() => ({
opacity: opacity.value, opacity: opacity.value,
transform: [{ translateY: translateY.value }], transform: [{ translateY: translateY.value }],
})); }));
useEffect(() => { useEffect(() => {
opacity.value = withDelay(delay, withTiming(1, { duration: 250 })); opacity.value = withDelay(delay, withTiming(1, { duration: 250 }));
translateY.value = withDelay(delay, withTiming(0, { duration: 250 })); translateY.value = withDelay(delay, withTiming(0, { duration: 250 }));
}, [delay]);
// Cleanup on unmount
useEffect(() => {
return () => {
opacity.value = 0;
translateY.value = 20;
};
}, []); }, []);
return ( return (
<Animated.View style={[style, animatedStyle]}> <Animated.View style={[style, animatedStyle]}>
{children} {children}
@ -381,6 +406,7 @@ const ProviderFilter = memo(({
initialNumToRender={5} initialNumToRender={5}
maxToRenderPerBatch={3} maxToRenderPerBatch={3}
windowSize={3} windowSize={3}
removeClippedSubviews={true}
getItemLayout={(data, index) => ({ getItemLayout={(data, index) => ({
length: 100, // Approximate width of each item length: 100, // Approximate width of each item
offset: 100 * index, offset: 100 * index,
@ -1608,6 +1634,9 @@ export const StreamsScreen = () => {
useEffect(() => { useEffect(() => {
return () => { return () => {
isMounted.current = false; isMounted.current = false;
// Clear scraper logo cache to free memory
scraperLogoCache.clear();
scraperLogoCachePromise = null;
}; };
}, []); }, []);
@ -1867,6 +1896,11 @@ export const StreamsScreen = () => {
windowSize={3} windowSize={3}
removeClippedSubviews={true} removeClippedSubviews={true}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
getItemLayout={(data, index) => ({
length: 78, // Approximate height of StreamCard (68 minHeight + 10 marginBottom)
offset: 78 * index,
index,
})}
/> />
) : ( ) : (
// Empty section placeholder // Empty section placeholder

View file

@ -304,7 +304,7 @@ Answer questions about this movie using only the verified database information a
'X-Title': 'Nuvio - AI Chat', 'X-Title': 'Nuvio - AI Chat',
}, },
body: JSON.stringify({ body: JSON.stringify({
model: 'openrouter/sonoma-dusk-alpha', model: 'x-ai/grok-4-fast:free',
messages, messages,
max_tokens: 1000, max_tokens: 1000,
temperature: 0.7, temperature: 0.7,