update image caching
This commit is contained in:
parent
f146f6a312
commit
230afd7414
6 changed files with 21 additions and 10 deletions
|
|
@ -60,7 +60,7 @@ const OptimizedImage: React.FC<OptimizedImageProps> = ({
|
||||||
onError,
|
onError,
|
||||||
contentFit = 'cover',
|
contentFit = 'cover',
|
||||||
transition = 200,
|
transition = 200,
|
||||||
cachePolicy = 'memory-disk'
|
cachePolicy = 'memory'
|
||||||
}) => {
|
}) => {
|
||||||
const [isLoaded, setIsLoaded] = useState(false);
|
const [isLoaded, setIsLoaded] = useState(false);
|
||||||
const [hasError, setHasError] = useState(false);
|
const [hasError, setHasError] = useState(false);
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ const ContentItem = ({ item, onPress, shouldLoadImage: shouldLoadImageProp, defe
|
||||||
source={{ uri: optimizedPosterUrl }}
|
source={{ uri: optimizedPosterUrl }}
|
||||||
style={[styles.poster, { backgroundColor: currentTheme.colors.elevation1, borderRadius: posterRadius }]}
|
style={[styles.poster, { backgroundColor: currentTheme.colors.elevation1, borderRadius: posterRadius }]}
|
||||||
contentFit="cover"
|
contentFit="cover"
|
||||||
cachePolicy={Platform.OS === 'android' ? 'disk' : 'memory-disk'}
|
cachePolicy="memory"
|
||||||
transition={0}
|
transition={0}
|
||||||
allowDownscaling
|
allowDownscaling
|
||||||
priority="normal" // Normal priority for horizontal scrolling
|
priority="normal" // Normal priority for horizontal scrolling
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ const HeroCarousel: React.FC<HeroCarouselProps> = ({ items, loading = false }) =
|
||||||
style={styles.backgroundImage as ImageStyle}
|
style={styles.backgroundImage as ImageStyle}
|
||||||
contentFit="cover"
|
contentFit="cover"
|
||||||
blurRadius={Platform.OS === 'android' ? 8 : 12}
|
blurRadius={Platform.OS === 'android' ? 8 : 12}
|
||||||
cachePolicy="memory-disk"
|
cachePolicy="memory"
|
||||||
transition={0}
|
transition={0}
|
||||||
priority="low"
|
priority="low"
|
||||||
/>
|
/>
|
||||||
|
|
@ -191,7 +191,7 @@ const HeroCarousel: React.FC<HeroCarouselProps> = ({ items, loading = false }) =
|
||||||
source={{ uri: data[activeIndex + 1].banner || data[activeIndex + 1].poster }}
|
source={{ uri: data[activeIndex + 1].banner || data[activeIndex + 1].poster }}
|
||||||
style={{ width: 1, height: 1 }}
|
style={{ width: 1, height: 1 }}
|
||||||
contentFit="cover"
|
contentFit="cover"
|
||||||
cachePolicy="memory-disk"
|
cachePolicy="memory"
|
||||||
transition={0}
|
transition={0}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
@ -200,7 +200,7 @@ const HeroCarousel: React.FC<HeroCarouselProps> = ({ items, loading = false }) =
|
||||||
source={{ uri: data[activeIndex - 1].banner || data[activeIndex - 1].poster }}
|
source={{ uri: data[activeIndex - 1].banner || data[activeIndex - 1].poster }}
|
||||||
style={{ width: 1, height: 1 }}
|
style={{ width: 1, height: 1 }}
|
||||||
contentFit="cover"
|
contentFit="cover"
|
||||||
cachePolicy="memory-disk"
|
cachePolicy="memory"
|
||||||
transition={0}
|
transition={0}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
@ -285,7 +285,7 @@ const CarouselCard: React.FC<CarouselCardProps> = memo(({ item, colors, logoFail
|
||||||
style={styles.banner as ImageStyle}
|
style={styles.banner as ImageStyle}
|
||||||
contentFit="cover"
|
contentFit="cover"
|
||||||
transition={0}
|
transition={0}
|
||||||
cachePolicy="memory-disk"
|
cachePolicy="memory"
|
||||||
/>
|
/>
|
||||||
<LinearGradient
|
<LinearGradient
|
||||||
colors={["transparent", "rgba(0,0,0,0.2)", "rgba(0,0,0,0.6)"]}
|
colors={["transparent", "rgba(0,0,0,0.2)", "rgba(0,0,0,0.6)"]}
|
||||||
|
|
@ -300,7 +300,7 @@ const CarouselCard: React.FC<CarouselCardProps> = memo(({ item, colors, logoFail
|
||||||
style={styles.logo as ImageStyle}
|
style={styles.logo as ImageStyle}
|
||||||
contentFit="contain"
|
contentFit="contain"
|
||||||
transition={0}
|
transition={0}
|
||||||
cachePolicy="memory-disk"
|
cachePolicy="memory"
|
||||||
onError={onLogoError}
|
onError={onLogoError}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
|
|
@ -403,11 +403,12 @@ const LibraryScreen = () => {
|
||||||
>
|
>
|
||||||
<View>
|
<View>
|
||||||
<View style={[styles.posterContainer, { shadowColor: currentTheme.colors.black }]}>
|
<View style={[styles.posterContainer, { shadowColor: currentTheme.colors.black }]}>
|
||||||
<Image
|
<Image
|
||||||
source={{ uri: item.poster || 'https://via.placeholder.com/300x450' }}
|
source={{ uri: item.poster || 'https://via.placeholder.com/300x450' }}
|
||||||
style={styles.poster}
|
style={styles.poster}
|
||||||
contentFit="cover"
|
contentFit="cover"
|
||||||
transition={300}
|
cachePolicy="memory"
|
||||||
|
transition={300}
|
||||||
/>
|
/>
|
||||||
{item.watched && (
|
{item.watched && (
|
||||||
<View style={styles.watchedIndicator}>
|
<View style={styles.watchedIndicator}>
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,8 @@ const TraktSettingsScreen: React.FC = () => {
|
||||||
await traktService.logout();
|
await traktService.logout();
|
||||||
setIsAuthenticated(false);
|
setIsAuthenticated(false);
|
||||||
setUserProfile(null);
|
setUserProfile(null);
|
||||||
|
// Refresh auth status in the integration hook to ensure UI consistency
|
||||||
|
await refreshAuthStatus();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('[TraktSettingsScreen] Error signing out:', error);
|
logger.error('[TraktSettingsScreen] Error signing out:', error);
|
||||||
openAlert('Error', 'Failed to sign out of Trakt.');
|
openAlert('Error', 'Failed to sign out of Trakt.');
|
||||||
|
|
@ -494,6 +496,14 @@ const TraktSettingsScreen: React.FC = () => {
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
<CustomAlert
|
||||||
|
visible={alertVisible}
|
||||||
|
title={alertTitle}
|
||||||
|
message={alertMessage}
|
||||||
|
onClose={() => setAlertVisible(false)}
|
||||||
|
actions={alertActions}
|
||||||
|
/>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ interface CachedImage {
|
||||||
|
|
||||||
class ImageCacheService {
|
class ImageCacheService {
|
||||||
private cache = new Map<string, CachedImage>();
|
private cache = new Map<string, CachedImage>();
|
||||||
private readonly CACHE_DURATION = 24 * 60 * 60 * 1000; // 24 hours
|
private readonly CACHE_DURATION = Infinity; // Session-only: valid until app close
|
||||||
private readonly MAX_CACHE_SIZE = 25; // Further reduced maximum number of cached images
|
private readonly MAX_CACHE_SIZE = 25; // Further reduced maximum number of cached images
|
||||||
private readonly MAX_MEMORY_MB = 40; // Further reduced maximum memory usage in MB
|
private readonly MAX_MEMORY_MB = 40; // Further reduced maximum memory usage in MB
|
||||||
private currentMemoryUsage = 0;
|
private currentMemoryUsage = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue