mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-24 23:07:25 +08:00
impr(account page): automatically enable results if both results and accuracy are disabled to avoid confusion
This commit is contained in:
parent
4f9ddd1a47
commit
e3a40b46b1
4 changed files with 26 additions and 81 deletions
|
|
@ -35,10 +35,6 @@ describe("Config", () => {
|
|||
false
|
||||
);
|
||||
});
|
||||
it("setAccountChartResults", () => {
|
||||
expect(Config.setAccountChartResults(true)).toBe(true);
|
||||
expect(Config.setAccountChartResults("on" as any)).toBe(false);
|
||||
});
|
||||
it("setStopOnError", () => {
|
||||
expect(Config.setStopOnError("off")).toBe(true);
|
||||
expect(Config.setStopOnError("word")).toBe(true);
|
||||
|
|
@ -254,17 +250,12 @@ describe("Config", () => {
|
|||
it("setBlindMode", () => {
|
||||
testBoolean(Config.setBlindMode);
|
||||
});
|
||||
it("setAccountChartResults", () => {
|
||||
testBoolean(Config.setAccountChartResults);
|
||||
});
|
||||
it("setAccountChartAccuracy", () => {
|
||||
testBoolean(Config.setAccountChartAccuracy);
|
||||
});
|
||||
it("setAccountChartAvg10", () => {
|
||||
testBoolean(Config.setAccountChartAvg10);
|
||||
});
|
||||
it("setAccountChartAvg100", () => {
|
||||
testBoolean(Config.setAccountChartAvg100);
|
||||
it("setAccountChart", () => {
|
||||
expect(Config.setAccountChart(["on", "off", "off", "on"])).toBe(true);
|
||||
expect(Config.setAccountChart(["on", "off"] as any)).toBe(true);
|
||||
expect(Config.setAccountChart(["on", "off", "on", "true"] as any)).toBe(
|
||||
false
|
||||
);
|
||||
});
|
||||
it("setAlwaysShowDecimalPlaces", () => {
|
||||
testBoolean(Config.setAlwaysShowDecimalPlaces);
|
||||
|
|
|
|||
|
|
@ -555,8 +555,8 @@
|
|||
<div class="text"></div>
|
||||
<div class="buttons">
|
||||
<button class="toggleResultsOnChart">
|
||||
<i class="fas fa-keyboard"></i>
|
||||
Results
|
||||
<i class="fas fa-tachometer-alt"></i>
|
||||
Speed
|
||||
</button>
|
||||
<button class="toggleAccuracyOnChart">
|
||||
<i class="fas fa-bullseye"></i>
|
||||
|
|
|
|||
|
|
@ -336,6 +336,12 @@ export function setAccountChart(
|
|||
return false;
|
||||
}
|
||||
|
||||
// if both speed and accuracy are off, set speed to on
|
||||
// i dedicate this fix to AshesOfAFallen and our 2 collective brain cells
|
||||
if (array[0] === "off" && array[1] === "off") {
|
||||
array[0] = "on";
|
||||
}
|
||||
|
||||
config.accountChart = array;
|
||||
saveToLocalStorage("accountChart", nosave);
|
||||
ConfigEvent.dispatch("accountChart", config.accountChart);
|
||||
|
|
@ -343,66 +349,6 @@ export function setAccountChart(
|
|||
return true;
|
||||
}
|
||||
|
||||
export function setAccountChartResults(
|
||||
value: boolean,
|
||||
nosave?: boolean
|
||||
): boolean {
|
||||
if (!isConfigValueValidBoolean("account chart results", value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
config.accountChart[0] = value ? "on" : "off";
|
||||
saveToLocalStorage("accountChart", nosave);
|
||||
ConfigEvent.dispatch("accountChart", config.accountChart);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function setAccountChartAccuracy(
|
||||
value: boolean,
|
||||
nosave?: boolean
|
||||
): boolean {
|
||||
if (!isConfigValueValidBoolean("account chart accuracy", value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
config.accountChart[1] = value ? "on" : "off";
|
||||
saveToLocalStorage("accountChart", nosave);
|
||||
ConfigEvent.dispatch("accountChart", config.accountChart);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function setAccountChartAvg10(
|
||||
value: boolean,
|
||||
nosave?: boolean
|
||||
): boolean {
|
||||
if (!isConfigValueValidBoolean("account chart avg 10", value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
config.accountChart[2] = value ? "on" : "off";
|
||||
saveToLocalStorage("accountChart", nosave);
|
||||
ConfigEvent.dispatch("accountChart", config.accountChart);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function setAccountChartAvg100(
|
||||
value: boolean,
|
||||
nosave?: boolean
|
||||
): boolean {
|
||||
if (!isConfigValueValidBoolean("account chart avg 100", value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
config.accountChart[3] = value ? "on" : "off";
|
||||
saveToLocalStorage("accountChart", nosave);
|
||||
ConfigEvent.dispatch("accountChart", config.accountChart);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function setStopOnError(
|
||||
soe: ConfigSchemas.StopOnError,
|
||||
nosave?: boolean
|
||||
|
|
|
|||
|
|
@ -1104,19 +1104,27 @@ function sortAndRefreshHistory(
|
|||
}
|
||||
|
||||
$(".pageAccount button.toggleResultsOnChart").on("click", () => {
|
||||
UpdateConfig.setAccountChartResults(!(Config.accountChart[0] === "on"));
|
||||
const newValue = Config.accountChart;
|
||||
newValue[0] = newValue[0] === "on" ? "off" : "on";
|
||||
UpdateConfig.setAccountChart(newValue);
|
||||
});
|
||||
|
||||
$(".pageAccount button.toggleAccuracyOnChart").on("click", () => {
|
||||
UpdateConfig.setAccountChartAccuracy(!(Config.accountChart[1] === "on"));
|
||||
const newValue = Config.accountChart;
|
||||
newValue[1] = newValue[1] === "on" ? "off" : "on";
|
||||
UpdateConfig.setAccountChart(newValue);
|
||||
});
|
||||
|
||||
$(".pageAccount button.toggleAverage10OnChart").on("click", () => {
|
||||
UpdateConfig.setAccountChartAvg10(!(Config.accountChart[2] === "on"));
|
||||
const newValue = Config.accountChart;
|
||||
newValue[2] = newValue[2] === "on" ? "off" : "on";
|
||||
UpdateConfig.setAccountChart(newValue);
|
||||
});
|
||||
|
||||
$(".pageAccount button.toggleAverage100OnChart").on("click", () => {
|
||||
UpdateConfig.setAccountChartAvg100(!(Config.accountChart[3] === "on"));
|
||||
const newValue = Config.accountChart;
|
||||
newValue[3] = newValue[3] === "on" ? "off" : "on";
|
||||
UpdateConfig.setAccountChart(newValue);
|
||||
});
|
||||
|
||||
$(".pageAccount .loadMoreButton").on("click", () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue