From c5f52d0e764b24a5e08e89cbb670322e0cb5a81e Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 24 Apr 2024 10:17:27 -0300 Subject: [PATCH] fix: Reload current sentence with updated show pronunciation setting in FlashCards component instead of loading a next/new sentence fixes Fix: *Reload* question after changing show pronunciation #10 --- src/components/FlashCards.svelte | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/FlashCards.svelte b/src/components/FlashCards.svelte index 729bd62..f190058 100644 --- a/src/components/FlashCards.svelte +++ b/src/components/FlashCards.svelte @@ -101,6 +101,14 @@ return questionText; } + /** + * Reloads the current sentence with the current settings. + * This is useful when the user changes the learning mode or the show pronunciation setting. + */ + function reloadCurrentSentence() { + questionText = getQuestionText(currentSentence, { learningMode, showPronunciation }); + } + function loadNextSentence() { currentTimeout ? clearTimeout(currentTimeout) : null; currentSentence = getNextSentence(); @@ -323,7 +331,7 @@ goto(url.href, { replaceState: true }); const newShowPronunciation = url.searchParams.get('showPronunciation') as 'true' | 'false'; showPronunciation = newShowPronunciation === 'true'; - loadNextSentence(); + reloadCurrentSentence(); } onMount(() => {