Build fixes

This commit is contained in:
Richard Roberson 2025-01-26 02:15:14 -07:00
parent 43d34fb2f7
commit 9374d3efbe
2 changed files with 82 additions and 82 deletions

View file

@ -4,7 +4,7 @@ import dynamic from 'next/dynamic';
import { usePDF } from '@/contexts/PDFContext'; import { usePDF } from '@/contexts/PDFContext';
import { useParams } from 'next/navigation'; import { useParams } from 'next/navigation';
import Link from 'next/link'; import Link from 'next/link';
import { use, useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { PDFSkeleton } from '@/components/PDFSkeleton'; import { PDFSkeleton } from '@/components/PDFSkeleton';
import { useTTS } from '@/contexts/TTSContext'; import { useTTS } from '@/contexts/TTSContext';

View file

@ -148,10 +148,10 @@ export function PDFProvider({ children }: { children: ReactNode }) {
} }
}, []); }, []);
function onDocumentLoadSuccess({ numPages }: { numPages: number }): void { const onDocumentLoadSuccess = useCallback(({ numPages }: { numPages: number }) => {
console.log('Document loaded:', numPages); console.log('Document loaded:', numPages);
setCurrDocPages(numPages); setCurrDocPages(numPages);
} }, []);
// Extract text from a PDF file // Extract text from a PDF file
const extractTextFromPDF = useCallback(async (pdfURL: string, currDocPage: number): Promise<string> => { const extractTextFromPDF = useCallback(async (pdfURL: string, currDocPage: number): Promise<string> => {
@ -267,18 +267,18 @@ export function PDFProvider({ children }: { children: ReactNode }) {
console.error('Failed to get document URL:', error); console.error('Failed to get document URL:', error);
setError('Failed to retrieve the document. Please try again.'); setError('Failed to retrieve the document. Please try again.');
} }
}, [getDocument, loadCurrDocText]); }, [getDocument]);
const clearCurrDoc = useCallback(() => { const clearCurrDoc = useCallback(() => {
setCurrDocName(undefined); setCurrDocName(undefined);
setCurrDocURL(undefined); setCurrDocURL(undefined);
setCurrDocText(undefined); setCurrDocText(undefined);
setCurrDocPages(undefined);
// Clear TTS text // Clear TTS text
setCurrDocPages(undefined); // Goes to TTS context
setTTSText(''); setTTSText('');
}, []); }, [setCurrDocPages, setTTSText]);
// Clear all highlights in the PDF viewer // Clear all highlights in the PDF viewer
const clearHighlights = useCallback(() => { const clearHighlights = useCallback(() => {