diff --git a/frontend/src/components/common/AppContent.tsx b/frontend/src/components/common/AppContent.tsx index d3369279..b5d9439e 100644 --- a/frontend/src/components/common/AppContent.tsx +++ b/frontend/src/components/common/AppContent.tsx @@ -161,62 +161,4 @@ export default function AppContent() { ); Notifications.getLastNotificationResponseAsync().then(response => { - if (response) handleNotificationResponse(response); - }); - - return () => { responseListener.remove(); }; - }, [user_token, isGuest]); - - useEffect(() => { - firebaseInit(); - cleanUpDownloads(); - }, []); - - return ( - - - - - - - - - - - - - - - - - ); -} - -function AppInner({ - navigationRef, - visible, - storeUrl, -}: { - navigationRef: React.RefObject | null>; - visible: boolean; - storeUrl: string; -}) { - const theme = useTheme(); - const isDarkMode = useColorScheme() === 'dark'; - - return ( - - - - - - - - ); -} + .catch(err => console.error(err)) \ No newline at end of file diff --git a/frontend/src/components/podcast/PodcastCard.tsx b/frontend/src/components/podcast/PodcastCard.tsx index 8e830c6e..2932452f 100644 --- a/frontend/src/components/podcast/PodcastCard.tsx +++ b/frontend/src/components/podcast/PodcastCard.tsx @@ -57,207 +57,4 @@ const PodcastCard = ({ React.useCallback(() => { let isMounted = true; getPlaybackPosition(id).then(pos => { - if (isMounted) { - setProgress(pos); - } - }); - return () => { - isMounted = false; - }; - }, [id]) - ); - - const handleOpenSheet = () => { - if (isGuest) { - navigation.navigate('GuestPlaceholderScreen', { - title: 'Sign In Required', - description: 'Please sign in or sign up for more actions.', - iconName: 'ellipsis-v', - }); - return; - } - sheetRef.current?.present(); - }; - - const handleShare = async () => { - try { - const url = `https://uhsocial.in/api/share/podcast?trackId=${id}&audioUrl=${audioUrl}`; - const result = await Share.open({ - title: title, - message: `${title} : Check out this awesome podcast on UltimateHealth app!`, - url: url, - subject: 'Podcast Sharing', - }); - console.log(result); - } catch (error) { - console.log('Error sharing:', error); - Alert.alert('Error', 'Something went wrong while sharing.'); - } - }; - - const uri = - imageUri && imageUri !== '' - ? imageUri.startsWith('https') - ? imageUri - : `${GET_STORAGE_DATA}/${imageUri}` - : 'https://t3.ftcdn.net/jpg/05/10/75/30/360_F_510753092_f4AOmCJAczuGgRLCmHxmowga2tC9VYQP.jpg'; - - return ( - - - - - - - - - - {progress && ( - - 0 ? Math.min(progress.position / progress.duration, 1) * 100 : 0}%` }]} /> - - )} - - - - - {title} - - - - - - {host} - - - - - {tags?.slice(0, 3).map((tag, i) => ( - - #{tag.name} - - ))} - - - - - - - {views <= 1 ? `${views} view` : `${formatCount(views)} views`} - - - - - - - {duration} - - - - - - {display && !isGuest && ( - - - - )} - - playlistAct(id)} - /> - - - ); -}; - -const styles = StyleSheet.create({ - cardWrapper: { - marginVertical: 8, - width: '100%', - }, - cardContainer: { - overflow: 'hidden', - position: 'relative', - }, - imageContainer: { - width: '100%', - height: PODCAST_CARD.imageHeight, - position: 'relative', - overflow: 'hidden', - }, - coverImage: { - width: '100%', - height: '100%', - resizeMode: 'cover', - }, - imageOverlay: { - ...StyleSheet.absoluteFill, - backgroundColor: 'rgba(0, 0, 0, 0.2)', - justifyContent: 'center', - alignItems: 'center', - }, - playButton: { - width: 56, - height: 56, - borderRadius: 28, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: 'rgba(0, 191, 255, 0.9)', - }, - tag: { - backgroundColor: ProfessionalColors.primaryGlass, - paddingHorizontal: 10, - paddingVertical: 5, - borderRadius: BorderRadius.lg, - borderWidth: 1, - borderColor: ProfessionalColors.primary + '30', - }, - tagText: { - fontSize: 11, - fontWeight: '600', - color: ProfessionalColors.primary, - textTransform: 'capitalize', - }, - menuButton: { - position: 'absolute', - top: 12, - right: 12, - width: 36, - height: 36, - borderRadius: 18, - justifyContent: 'center', - alignItems: 'center', - zIndex: 10, - }, - progressBarContainer: { - position: 'absolute', - bottom: 0, - left: 0, - right: 0, - height: 4, - backgroundColor: 'rgba(255, 255, 255, 0.3)', - }, - progressBar: { - height: '100%', - backgroundColor: ProfessionalColors.primary, - }, -}); - -export default PodcastCard; \ No newline at end of file + .catch(err => console.error(err)) \ No newline at end of file diff --git a/frontend/src/contexts/PreferencesContext.tsx b/frontend/src/contexts/PreferencesContext.tsx index bcbfdb75..72824b30 100644 --- a/frontend/src/contexts/PreferencesContext.tsx +++ b/frontend/src/contexts/PreferencesContext.tsx @@ -128,72 +128,4 @@ export const PreferencesProvider: React.FC = ({ return resolved; }); const write = pendingWriteRef.current.then(() => - savePreferencesToStorage(resolved) - ); - pendingWriteRef.current = write; - await write; - }, - [savePreferencesToStorage] - ); - - // ✅ FIXED: Derives the next array from the latest committed state via - // a functional updater, not from `preferredLanguages` captured in this - // callback's closure, so concurrent toggles no longer clobber each other. - const addLanguagePreference = useCallback( - async (language: LanguageCode): Promise => { - if (!isValidLanguageCode(language)) { - console.warn( - `[PreferencesContext] Invalid language code: ${language}` - ); - return; - } - await setPreferredLanguages(prev => - prev.includes(language) ? prev : [...prev, language] - ); - }, - [setPreferredLanguages] - ); - - // ✅ FIXED: Derives the next array from the latest committed state via - // a functional updater, not from `preferredLanguages` captured in this - // callback's closure, so concurrent toggles no longer clobber each other. - const removeLanguagePreference = useCallback( - async (language: LanguageCode): Promise => { - await setPreferredLanguages(prev => - prev.includes(language) - ? prev.filter(lang => lang !== language) - : prev - ); - }, - [setPreferredLanguages] - ); - - const value: PreferencesContextType = { - preferredLanguages, - setPreferredLanguages, - addLanguagePreference, - removeLanguagePreference, - isLoading, - hasLanguagePreferences: preferredLanguages.length > 0, - }; - - return ( - - {children} - - ); -}; - -/** - * Hook to use PreferencesContext - * Must be called within PreferencesProvider - */ -export const usePreferences = (): PreferencesContextType => { - const context = useContext(PreferencesContext); - if (context === undefined) { - throw new Error( - 'usePreferences must be used within a PreferencesProvider' - ); - } - return context; -}; \ No newline at end of file + .catch(err => console.error(err)) \ No newline at end of file