moved the code responsible for removing trailing afk from bailed out tests to the test finish function

This commit is contained in:
Miodec 2023-04-17 16:37:31 +02:00
parent 7633155336
commit 73d2db4799
2 changed files with 6 additions and 5 deletions

View file

@ -1555,6 +1555,11 @@ export async function finish(difficultyFailed = false): Promise<void> {
TestInput.forceKeyup(now); //this ensures that the last keypress(es) are registered
const endAfkSeconds = (now - TestInput.keypressTimings.spacing.last) / 1000;
if ((Config.mode == "zen" || TestInput.bailout) && endAfkSeconds < 7) {
TestStats.setEnd(TestInput.keypressTimings.spacing.last);
}
TestUI.setResultCalculating(true);
TestUI.setResultVisible(true);
TestState.setActive(false);

View file

@ -186,16 +186,12 @@ export function setInvalid(): void {
export function calculateTestSeconds(now?: number): number {
if (now === undefined) {
const endAfkSeconds = (end - TestInput.lastKeypress) / 1000;
if ((Config.mode == "zen" || TestInput.bailout) && endAfkSeconds < 7) {
return (TestInput.lastKeypress - start) / 1000;
} else {
return (end - start) / 1000;
}
} else {
return (now - start) / 1000;
}
}
let avg = 0;
export function calculateWpmAndRaw(): MonkeyTypes.WordsPerMinuteAndRaw {
const start = performance.now();