Skip to content

Commit 86be935

Browse files
committed
Fully unified navigation system
1 parent d447132 commit 86be935

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/contexts/TTSContext.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,6 @@ export function TTSProvider({ children }: { children: ReactNode }) {
143143

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

146-
/**
147-
* Changes the current page by a specified amount
148-
*
149-
* @param {number} [num=1] - The number of pages to increment by
150-
*/
151-
const incrementPage = useCallback((num = 1) => {
152-
setNextPageLoading(true);
153-
setCurrDocPage(currDocPageNumber + num);
154-
}, [currDocPageNumber]);
155-
156146
/**
157147
* Processes text through the NLP API to split it into sentences
158148
*
@@ -340,7 +330,7 @@ export function TTSProvider({ children }: { children: ReactNode }) {
340330
console.log('PDF: Advancing to next/prev page');
341331
setCurrentIndex(0);
342332
setSentences([]);
343-
incrementPage(nextIndex >= sentences.length ? 1 : -1);
333+
skipToLocation(currDocPageNumber + (nextIndex >= sentences.length ? 1 : -1), true);
344334
return;
345335
}
346336

@@ -350,18 +340,15 @@ export function TTSProvider({ children }: { children: ReactNode }) {
350340
setIsPlaying(false);
351341
}
352342
}
353-
}, [currentIndex, incrementPage, sentences, currDocPageNumber, currDocPages, isEPUB]);
343+
}, [currentIndex, sentences, currDocPageNumber, currDocPages, isEPUB, skipToLocation]);
354344

355345
/**
356346
* Moves forward one sentence in the text
357347
*/
358348
const skipForward = useCallback(() => {
359349
setIsProcessing(true);
360-
361350
abortAudio();
362-
363351
advance();
364-
365352
setIsProcessing(false);
366353
}, [abortAudio, advance]);
367354

0 commit comments

Comments
 (0)