impr(account page): automatically enable results if both results and accuracy are disabled to avoid confusion

This commit is contained in:
Miodec 2024-08-15 11:37:38 +02:00
parent 4f9ddd1a47
commit e3a40b46b1
4 changed files with 26 additions and 81 deletions

View file

@ -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);

View file

@ -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>

View file

@ -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

View file

@ -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", () => {