11import React , { useState , useEffect , useRef , useMemo , useCallback } from 'react' ;
2- import { View , Text , ScrollView , StyleSheet , Pressable , Alert , ActivityIndicator , TouchableOpacity , TextInput , RefreshControl , Animated , Platform , Keyboard } from 'react-native' ;
2+ import { View , Text , ScrollView , StyleSheet , Pressable , Alert , ActivityIndicator , TouchableOpacity , RefreshControl , Animated , Keyboard } from 'react-native' ;
33import AsyncStorage from '@react-native-async-storage/async-storage' ;
44import * as Haptics from 'expo-haptics' ;
5- import { SafeAreaView } from 'react-native-safe-area-context' ;
65import { useFocusEffect } from '@react-navigation/native' ;
76import { useTheme } from '../theme' ;
87import { useApiService , type Note , type Folder } from '../services/api' ;
98import { Ionicons } from '@expo/vector-icons' ;
10- import { NOTE_CARD , FOLDER_CARD , ACTION_BUTTON , SECTION , FOLDER_COLORS } from '../constants/ui' ;
9+ import { NOTE_CARD , FOLDER_CARD , SECTION , FOLDER_COLORS } from '../constants/ui' ;
1110import { BottomSheetModal , BottomSheetView , BottomSheetBackdrop , BottomSheetTextInput } from '@gorhom/bottom-sheet' ;
1211
1312interface Props {
@@ -17,42 +16,26 @@ interface Props {
1716 scrollY ?: Animated . Value ;
1817}
1918
20- // Helper functions for view types
21- function getViewTitle ( viewType : string ) : string {
22- switch ( viewType ) {
23- case 'all' : return 'All Notes' ;
24- case 'starred' : return 'Starred' ;
25- case 'archived' : return 'Archived' ;
26- case 'trash' : return 'Trash' ;
27- default : return 'Notes' ;
28- }
29- }
30-
31- function getViewSubtitle ( viewType : string ) : string {
32- switch ( viewType ) {
33- case 'all' : return 'All your active notes' ;
34- case 'starred' : return 'Your starred notes' ;
35- case 'archived' : return 'Your archived notes' ;
36- case 'trash' : return 'Your deleted notes' ;
37- default : return 'Your secure notes' ;
38- }
39- }
40-
4119// Helper function to strip HTML tags and decode entities
4220function stripHtmlTags ( html : string ) : string {
4321 if ( ! html ) return '' ;
4422
45- // Remove HTML tags
46- let text = html . replace ( / < [ ^ > ] * > / g, '' ) ;
23+ // Remove HTML tags (apply repeatedly to handle nested/incomplete tags)
24+ let previous ;
25+ let text = html ;
26+ do {
27+ previous = text ;
28+ text = text . replace ( / < [ ^ > ] * > / g, '' ) ;
29+ } while ( text !== previous ) ;
4730
48- // Decode common HTML entities
31+ // Decode common HTML entities (decode & last to prevent double-unescaping)
4932 text = text
50- . replace ( / & a m p ; / g, '&' )
5133 . replace ( / & l t ; / g, '<' )
5234 . replace ( / & g t ; / g, '>' )
5335 . replace ( / & q u o t ; / g, '"' )
5436 . replace ( / & # 3 9 ; / g, "'" )
55- . replace ( / & n b s p ; / g, ' ' ) ;
37+ . replace ( / & n b s p ; / g, ' ' )
38+ . replace ( / & a m p ; / g, '&' ) ;
5639
5740 // Remove extra whitespace and normalize
5841 text = text . replace ( / \s + / g, ' ' ) . trim ( ) ;
@@ -63,7 +46,7 @@ function stripHtmlTags(html: string): string {
6346export default function NotesListScreen ( { navigation, route, renderHeader, scrollY : parentScrollY } : Props ) {
6447 const theme = useTheme ( ) ;
6548 const api = useApiService ( ) ;
66- const { folderId, folderName , viewType, searchQuery } = route ?. params || { } ;
49+ const { folderId, viewType, searchQuery } = route ?. params || { } ;
6750
6851 const [ notes , setNotes ] = useState < Note [ ] > ( [ ] ) ;
6952 const [ subfolders , setSubfolders ] = useState < Folder [ ] > ( [ ] ) ;
@@ -76,7 +59,6 @@ export default function NotesListScreen({ navigation, route, renderHeader, scrol
7659 const [ newFolderName , setNewFolderName ] = useState ( '' ) ;
7760 const [ selectedColor , setSelectedColor ] = useState ( '#3b82f6' ) ;
7861 const [ isCreatingFolder , setIsCreatingFolder ] = useState ( false ) ;
79- const [ showFabMenu , setShowFabMenu ] = useState ( false ) ;
8062 const [ viewMode , setViewMode ] = useState < 'list' | 'grid' > ( 'list' ) ;
8163
8264 // Bottom sheet ref
0 commit comments