@@ -39,7 +39,6 @@ interface PDFContextType {
3939 getDocument : ( id : string ) => Promise < PDFDocument | undefined > ;
4040 removeDocument : ( id : string ) => Promise < void > ;
4141 isLoading : boolean ;
42- error : string | null ;
4342 extractTextFromPDF : ( pdfURL : string , currDocPage : number ) => Promise < string > ;
4443 highlightPattern : ( text : string , pattern : string , containerRef : React . RefObject < HTMLDivElement > ) => void ;
4544 clearHighlights : ( ) => void ;
@@ -65,7 +64,6 @@ const PDFContext = createContext<PDFContextType | undefined>(undefined);
6564export function PDFProvider ( { children } : { children : ReactNode } ) {
6665 const [ documents , setDocuments ] = useState < PDFDocument [ ] > ( [ ] ) ;
6766 const [ isLoading , setIsLoading ] = useState ( true ) ;
68- const [ error , setError ] = useState < string | null > ( null ) ;
6967
7068 const { isDBReady } = useConfig ( ) ;
7169 const {
@@ -86,12 +84,10 @@ export function PDFProvider({ children }: { children: ReactNode }) {
8684 if ( ! isDBReady ) return ;
8785
8886 try {
89- setError ( null ) ;
9087 const docs = await indexedDBService . getAllDocuments ( ) ;
9188 setDocuments ( docs ) ;
9289 } catch ( error ) {
9390 console . error ( 'Failed to load documents:' , error ) ;
94- setError ( 'Failed to load documents. Please try again.' ) ;
9591 } finally {
9692 setIsLoading ( false ) ;
9793 }
@@ -102,7 +98,6 @@ export function PDFProvider({ children }: { children: ReactNode }) {
10298
10399 // Add a new document to IndexedDB
104100 const addDocument = useCallback ( async ( file : File ) : Promise < string > => {
105- setError ( null ) ;
106101 const id = uuidv4 ( ) ;
107102 const newDoc : PDFDocument = {
108103 id,
@@ -118,32 +113,27 @@ export function PDFProvider({ children }: { children: ReactNode }) {
118113 return id ;
119114 } catch ( error ) {
120115 console . error ( 'Failed to add document:' , error ) ;
121- setError ( 'Failed to save the document. Please try again.' ) ;
122116 throw error ;
123117 }
124118 } , [ ] ) ;
125119
126120 // Get a document by ID from IndexedDB
127121 const getDocument = useCallback ( async ( id : string ) : Promise < PDFDocument | undefined > => {
128- setError ( null ) ;
129122 try {
130123 return await indexedDBService . getDocument ( id ) ;
131124 } catch ( error ) {
132125 console . error ( 'Failed to get document:' , error ) ;
133- setError ( 'Failed to retrieve the document. Please try again.' ) ;
134126 return undefined ;
135127 }
136128 } , [ ] ) ;
137129
138130 // Remove a document by ID from IndexedDB
139131 const removeDocument = useCallback ( async ( id : string ) : Promise < void > => {
140- setError ( null ) ;
141132 try {
142133 await indexedDBService . removeDocument ( id ) ;
143134 setDocuments ( ( prev ) => prev . filter ( ( doc ) => doc . id !== id ) ) ;
144135 } catch ( error ) {
145136 console . error ( 'Failed to remove document:' , error ) ;
146- setError ( 'Failed to remove the document. Please try again.' ) ;
147137 throw error ;
148138 }
149139 } , [ ] ) ;
@@ -241,7 +231,6 @@ export function PDFProvider({ children }: { children: ReactNode }) {
241231 setTTSText ( text ) ;
242232 } catch ( error ) {
243233 console . error ( 'Error loading PDF text:' , error ) ;
244- setError ( 'Failed to extract PDF text' ) ;
245234 }
246235 } , [ currDocURL , currDocPage , extractTextFromPDF , setTTSText ] ) ;
247236
@@ -254,7 +243,6 @@ export function PDFProvider({ children }: { children: ReactNode }) {
254243
255244 // Set curr document
256245 const setCurrentDocument = useCallback ( async ( id : string ) : Promise < void > => {
257- setError ( null ) ;
258246 try {
259247 const doc = await getDocument ( id ) ;
260248 if ( doc ) {
@@ -265,7 +253,6 @@ export function PDFProvider({ children }: { children: ReactNode }) {
265253 }
266254 } catch ( error ) {
267255 console . error ( 'Failed to get document URL:' , error ) ;
268- setError ( 'Failed to retrieve the document. Please try again.' ) ;
269256 }
270257 } , [ getDocument ] ) ;
271258
@@ -463,7 +450,6 @@ export function PDFProvider({ children }: { children: ReactNode }) {
463450 getDocument,
464451 removeDocument,
465452 isLoading,
466- error,
467453 extractTextFromPDF,
468454 highlightPattern,
469455 clearHighlights,
@@ -483,7 +469,6 @@ export function PDFProvider({ children }: { children: ReactNode }) {
483469 getDocument ,
484470 removeDocument ,
485471 isLoading ,
486- error ,
487472 extractTextFromPDF ,
488473 highlightPattern ,
489474 clearHighlights ,
0 commit comments