Skip to content

Commit

Permalink
Fully unified navigation system
Browse files Browse the repository at this point in the history
  • Loading branch information
richardr1126 committed Feb 19, 2025
1 parent d447132 commit 86be935
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/contexts/TTSContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,6 @@ export function TTSProvider({ children }: { children: ReactNode }) {

//console.log('page:', currDocPage, 'pages:', currDocPages);

/**
* Changes the current page by a specified amount
*
* @param {number} [num=1] - The number of pages to increment by
*/
const incrementPage = useCallback((num = 1) => {
setNextPageLoading(true);
setCurrDocPage(currDocPageNumber + num);
}, [currDocPageNumber]);

/**
* Processes text through the NLP API to split it into sentences
*
Expand Down Expand Up @@ -340,7 +330,7 @@ export function TTSProvider({ children }: { children: ReactNode }) {
console.log('PDF: Advancing to next/prev page');
setCurrentIndex(0);
setSentences([]);
incrementPage(nextIndex >= sentences.length ? 1 : -1);
skipToLocation(currDocPageNumber + (nextIndex >= sentences.length ? 1 : -1), true);
return;
}

Expand All @@ -350,18 +340,15 @@ export function TTSProvider({ children }: { children: ReactNode }) {
setIsPlaying(false);
}
}
}, [currentIndex, incrementPage, sentences, currDocPageNumber, currDocPages, isEPUB]);
}, [currentIndex, sentences, currDocPageNumber, currDocPages, isEPUB, skipToLocation]);

/**
* Moves forward one sentence in the text
*/
const skipForward = useCallback(() => {
setIsProcessing(true);

abortAudio();

advance();

setIsProcessing(false);
}, [abortAudio, advance]);

Expand Down

0 comments on commit 86be935

Please # to comment.