Skip to content

Commit

Permalink
fix: Reload current sentence with updated show pronunciation setting …
Browse files Browse the repository at this point in the history
…in FlashCards component instead of loading a next/new sentence

fixes Fix: *Reload* question after changing show pronunciation #10
  • Loading branch information
drikusroor committed Apr 24, 2024
1 parent bd6d6d7 commit c5f52d0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/FlashCards.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -323,7 +331,7 @@
goto(url.href, { replaceState: true });
const newShowPronunciation = url.searchParams.get('showPronunciation') as 'true' | 'false';
showPronunciation = newShowPronunciation === 'true';
loadNextSentence();
reloadCurrentSentence();
}
onMount(() => {
Expand Down

0 comments on commit c5f52d0

Please sign in to comment.