-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: add "Previous Test" functionality with button and state management (@abhaychandra123) #7698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,6 +169,7 @@ type RestartOptions = { | |
| practiseMissed?: boolean; | ||
| noAnim?: boolean; | ||
| isQuickRestart?: boolean; | ||
| isPrevious?: boolean; | ||
| }; | ||
|
Comment on lines
169
to
173
|
||
|
|
||
| export function restart(options = {} as RestartOptions): void { | ||
|
|
@@ -346,7 +347,7 @@ export function restart(options = {} as RestartOptions): void { | |
| TestState.setPaceRepeat(repeatWithPace); | ||
| TestInitFailed.hide(); | ||
| TestState.setTestInitSuccess(true); | ||
| const initResult = await init(); | ||
| const initResult = await init(options.isPrevious ?? false); | ||
|
|
||
| if (!initResult) { | ||
| TestState.setTestRestarting(false); | ||
|
|
@@ -380,7 +381,7 @@ let lastInitError: Error | null = null; | |
| let showedLazyModeNotification: boolean = false; | ||
| let testReinitCount = 0; | ||
|
|
||
| async function init(): Promise<boolean> { | ||
| async function init(loadPreviousQuote = false): Promise<boolean> { | ||
| console.debug("Initializing test"); | ||
| testReinitCount++; | ||
| if (testReinitCount > 3) { | ||
|
|
@@ -413,7 +414,7 @@ async function init(): Promise<boolean> { | |
| } | ||
|
|
||
| if (!language || language.name !== Config.language) { | ||
| return await init(); | ||
| return await init(loadPreviousQuote); | ||
| } | ||
|
|
||
| if (getActivePage() === "test") { | ||
|
|
@@ -512,7 +513,9 @@ async function init(): Promise<boolean> { | |
| let generatedWords: string[] = []; | ||
| let generatedSectionIndexes: number[] = []; | ||
| try { | ||
| const gen = await WordsGenerator.generateWords(language); | ||
| const gen = await WordsGenerator.generateWords(language, { | ||
| loadPreviousQuote, | ||
| }); | ||
| generatedWords = gen.words; | ||
| generatedSectionIndexes = gen.sectionIndexes; | ||
| wordsHaveTab = gen.hasTab; | ||
|
|
@@ -537,7 +540,7 @@ async function init(): Promise<boolean> { | |
| }); | ||
| } | ||
|
|
||
| return await init(); | ||
| return await init(loadPreviousQuote); | ||
| } | ||
|
|
||
| let hasNumbers = false; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.