mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-29 02:07:55 +08:00
improved account page performance by not updating the account chart 5 times
This commit is contained in:
parent
014e20cf82
commit
2749360d3e
2 changed files with 10 additions and 15 deletions
|
|
@ -951,9 +951,9 @@ type ButtonBelowChart =
|
|||
| ".toggleAverage100OnChart";
|
||||
|
||||
export function updateAccountChartButtons(): void {
|
||||
updateAccuracy();
|
||||
updateAverage10();
|
||||
updateAverage100();
|
||||
updateAccuracy(false);
|
||||
updateAverage10(false);
|
||||
updateAverage100(false);
|
||||
}
|
||||
|
||||
function updateAccountChartButton(
|
||||
|
|
@ -965,7 +965,7 @@ function updateAccountChartButton(
|
|||
: $(`.pageAccount ${className}`).removeClass("active");
|
||||
}
|
||||
|
||||
function updateAccuracy(): void {
|
||||
function updateAccuracy(updateChart = true): void {
|
||||
const accOn = Config.accountChart[0] === "on";
|
||||
updateAccountChartButton(accOn, ".toggleAccuracyOnChart");
|
||||
|
||||
|
|
@ -975,10 +975,10 @@ function updateAccuracy(): void {
|
|||
|
||||
(accountHistory.options as ScaleChartOptions<"line">).scales["acc"].display =
|
||||
accOn;
|
||||
accountHistory.update();
|
||||
if (updateChart) accountHistory.updateColors();
|
||||
}
|
||||
|
||||
function updateAverage10(): void {
|
||||
function updateAverage10(updateChart = true): void {
|
||||
const accOn = Config.accountChart[0] === "on";
|
||||
const avg10On = Config.accountChart[1] === "on";
|
||||
updateAccountChartButton(avg10On, ".toggleAverage10OnChart");
|
||||
|
|
@ -989,11 +989,10 @@ function updateAverage10(): void {
|
|||
} else {
|
||||
accountHistory.data.datasets[3].hidden = !avg10On;
|
||||
}
|
||||
accountHistory.updateColors();
|
||||
accountHistory.update();
|
||||
if (updateChart) accountHistory.updateColors();
|
||||
}
|
||||
|
||||
function updateAverage100(): void {
|
||||
function updateAverage100(updateChart = true): void {
|
||||
const accOn = Config.accountChart[0] === "on";
|
||||
const avg100On = Config.accountChart[2] === "on";
|
||||
updateAccountChartButton(avg100On, ".toggleAverage100OnChart");
|
||||
|
|
@ -1004,8 +1003,7 @@ function updateAverage100(): void {
|
|||
} else {
|
||||
accountHistory.data.datasets[5].hidden = !avg100On;
|
||||
}
|
||||
accountHistory.updateColors();
|
||||
accountHistory.update();
|
||||
if (updateChart) accountHistory.updateColors();
|
||||
}
|
||||
|
||||
export async function updateColors<
|
||||
|
|
|
|||
|
|
@ -1022,14 +1022,11 @@ function fillContent(): void {
|
|||
$(".pageAccount .estimatedWordsTyped .val").text(totalEstimatedWords);
|
||||
|
||||
if (chartData.length || accChartData.length) {
|
||||
ChartController.updateAccountChartButtons();
|
||||
ChartController.accountHistory.options.animation = false;
|
||||
ChartController.accountHistory.update();
|
||||
delete ChartController.accountHistory.options.animation;
|
||||
}
|
||||
|
||||
if (chartData.length) {
|
||||
ChartController.updateAccountChartButtons();
|
||||
}
|
||||
ChartController.accountActivity.update();
|
||||
ChartController.accountHistogram.update();
|
||||
LoadingPage.updateBar(100, true);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue