From ed4132b650954c874f6d4c5ee991438e709356e4 Mon Sep 17 00:00:00 2001 From: Roni Laukkarinen Date: Sun, 1 Feb 2026 21:38:05 +0200 Subject: [PATCH] Fix words per display setting and limit max to 3 --- CHANGELOG.md | 1 + src/App.jsx | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 206a806..21101e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### 2026-02-01: 1.0.4 * Improve mobile responsiveness and book metadata layout +* Fix words per display setting and limit max to 3 ### 2026-02-01: 1.0.3 diff --git a/src/App.jsx b/src/App.jsx index 5791e66..e81019f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -396,11 +396,11 @@ function App() { timeoutRef.current = setTimeout(() => { setCurrentIndex((prev) => { - if (prev + 1 >= words.length) { + if (prev + wordAmount >= words.length) { setIsPlaying(false); return prev; } - return prev + 1; + return prev + wordAmount; }); }, delay); } @@ -410,7 +410,7 @@ function App() { clearTimeout(timeoutRef.current); } }; - }, [isPlaying, currentIndex, words, getBaseDelay]); + }, [isPlaying, currentIndex, words, getBaseDelay, wordAmount]); useEffect(() => { const handleKeyDown = (e) => { @@ -465,9 +465,10 @@ function App() { return () => window.removeEventListener("keydown", handleKeyDown); }, [isPlaying, words.length]); - const getCurrentWord = () => { + const getCurrentWords = () => { if (words.length === 0) return ""; - return words[currentIndex] || ""; + const endIndex = Math.min(currentIndex + wordAmount, words.length); + return words.slice(currentIndex, endIndex).join(" "); }; const togglePlay = () => { @@ -502,12 +503,14 @@ function App() { const progress = words.length > 0 ? ((currentIndex + 1) / words.length) * 100 : 0; - const currentWord = getCurrentWord(); - const orpIndex = getORPIndex(currentWord.length); + const currentText = getCurrentWords(); + // For ORP, use the first word when displaying multiple words + const firstWord = words[currentIndex] || ""; + const orpIndex = getORPIndex(firstWord.length); - const beforeORP = currentWord.slice(0, orpIndex); - const orpChar = currentWord[orpIndex] || ""; - const afterORP = currentWord.slice(orpIndex + 1); + const beforeORP = currentText.slice(0, orpIndex); + const orpChar = currentText[orpIndex] || ""; + const afterORP = currentText.slice(orpIndex + 1); return (
@@ -622,7 +625,7 @@ function App() {
- {currentWord ? ( + {currentText ? (
{wordAmount}