added pace caret: last closes #3113

This commit is contained in:
Miodec 2022-06-15 19:35:01 +02:00
parent f02649ae9f
commit 3da4eb45c0
7 changed files with 26 additions and 5 deletions

View file

@ -76,7 +76,7 @@ const CONFIG_SCHEMA = joi.object({
startGraphsAtZero: joi.boolean(),
swapEscAndTab: joi.boolean(),
showOutOfFocusWarning: joi.boolean(),
paceCaret: joi.string().valid("off", "average", "pb", "custom"),
paceCaret: joi.string().valid("off", "average", "pb", "last", "custom"),
paceCaretCustomSpeed: joi.number().min(0),
repeatedPace: joi.boolean(),
pageWidth: joi.string().valid("100", "125", "150", "200", "max"),

View file

@ -355,7 +355,9 @@ export function setPaceCaret(
nosave?: boolean
): boolean {
if (
!isConfigValueValid("pace caret", val, [["custom", "off", "average", "pb"]])
!isConfigValueValid("pace caret", val, [
["custom", "off", "average", "pb", "last"],
])
) {
return false;
}

View file

@ -1492,6 +1492,15 @@ const commandsPaceCaret: MonkeyTypes.CommandsGroup = {
TestLogic.restart();
},
},
{
id: "setPaceCaretLast",
display: "last",
configValue: "last",
exec: (): void => {
UpdateConfig.setPaceCaret("last");
TestLogic.restart();
},
},
{
id: "setPaceCaretAverage",
display: "average",

View file

@ -100,6 +100,8 @@ export async function update(): Promise<void> {
? "average"
: Config.paceCaret === "pb"
? "pb"
: Config.paceCaret === "last"
? "last"
: "custom"
} pace${speed}</div>`
);

View file

@ -77,7 +77,7 @@ export async function init(): Promise<void> {
wpm = Math.round(wpm);
} else if (Config.paceCaret === "custom") {
wpm = Config.paceCaretCustomSpeed;
} else if (TestState.isPaceRepeat == true) {
} else if (Config.paceCaret === "last" || TestState.isPaceRepeat == true) {
wpm = TestStats.lastTestWpm;
}
if (wpm === undefined || wpm < 1 || Number.isNaN(wpm)) {

View file

@ -92,7 +92,7 @@ declare namespace MonkeyTypes {
type SoundVolume = "0.1" | "0.5" | "1.0";
type PaceCaret = "off" | "average" | "pb" | "custom";
type PaceCaret = "off" | "average" | "pb" | "last" | "custom";
type PageWidth = "100" | "125" | "150" | "200" | "max";

View file

@ -1022,7 +1022,7 @@
tabindex="0"
onclick="this.blur();"
>
average
avg
</div>
<div
class="button"
@ -1032,6 +1032,14 @@
>
pb
</div>
<div
class="button"
paceCaret="last"
tabindex="0"
onclick="this.blur();"
>
last
</div>
<div
class="button"
paceCaret="custom"