@@ -2,6 +2,7 @@ import { useUser } from '@clerk/clerk-expo';
22import { BottomSheetModal } from '@gorhom/bottom-sheet' ;
33import AsyncStorage from '@react-native-async-storage/async-storage' ;
44import { useFocusEffect } from '@react-navigation/native' ;
5+ import { useRouter } from 'expo-router' ;
56import React , { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
67import { ActivityIndicator , Alert , Animated , FlatList , RefreshControl , StyleSheet , View } from 'react-native' ;
78
@@ -39,6 +40,7 @@ export default function NotesListScreen({ navigation, route, renderHeader, scrol
3940 const theme = useTheme ( ) ;
4041 const { user } = useUser ( ) ;
4142 const api = useApiService ( ) ;
43+ const router = useRouter ( ) ;
4244 const { folderId, viewType, searchQuery } = route ?. params || { } ;
4345
4446 const [ refreshing , setRefreshing ] = useState ( false ) ;
@@ -137,10 +139,13 @@ export default function NotesListScreen({ navigation, route, renderHeader, scrol
137139 // Empty the trash using the API
138140 const result = await api . emptyTrash ( ) ;
139141
140- // Reload notes to update the view
141- await loadNotes ( true ) ;
142+ // Navigate to main folders screen
143+ router . replace ( '/' ) ;
142144
143- Alert . alert ( 'Success' , `${ result . deletedCount } notes permanently deleted.` ) ;
145+ // Show success alert after navigation
146+ setTimeout ( ( ) => {
147+ Alert . alert ( 'Success' , `${ result . deletedCount } notes permanently deleted.` ) ;
148+ } , 300 ) ;
144149 } catch ( error ) {
145150 if ( __DEV__ ) console . error ( 'Failed to empty trash:' , error ) ;
146151 Alert . alert ( 'Error' , 'Failed to empty trash. Please try again.' ) ;
0 commit comments