From aa2b0eece824cf098b5b07efa600d3b9df4741bc Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 10 Feb 2022 21:24:46 +0100 Subject: [PATCH] fixes --- frontend/src/js/config.js | 6 ++--- frontend/src/js/test/test-ui.js | 42 +++++++++++++++++---------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/frontend/src/js/config.js b/frontend/src/js/config.js index 688976d41..9aa86b6c9 100644 --- a/frontend/src/js/config.js +++ b/frontend/src/js/config.js @@ -27,9 +27,9 @@ export let localStorageConfig = null; export let dbConfigLoaded = false; export let changedBeforeDb = false; -let eventSubscribers = []; +const eventSubscribers = []; -export function subscribe(fn) { +export function subscribeToEvent(fn) { eventSubscribers.push(fn); } @@ -321,7 +321,7 @@ function updateChartAccuracy() { ChartController.accountHistory.update(); } -export function updateChartStyle() { +function updateChartStyle() { if (config.chartStyle == "scatter") { ChartController.accountHistory.data.datasets[0].showLine = false; ChartController.accountHistory.data.datasets[1].showLine = false; diff --git a/frontend/src/js/test/test-ui.js b/frontend/src/js/test/test-ui.js index ae1022a86..3281fe37a 100644 --- a/frontend/src/js/test/test-ui.js +++ b/frontend/src/js/test/test-ui.js @@ -23,26 +23,28 @@ import * as UI from "../ui"; import * as SlowTimer from "../states/slow-timer"; import * as ReportQuotePopup from "../popups/quote-report-popup"; -UpdateConfig.subscribe((key, value) => { - if ( - [ - "difficulty", - "blindMode", - "stopOnError", - "paceCaret", - "minWpm", - "minAcc", - "minBurst", - "confidenceMode", - "layout", - ].includes(key) - ) { - updateModesNotice(); - } - if (key === "flipTestColors") flipColors(value); - if (key === "colorfulMode") colorful(value); - if (key === "highlightMode") updateWordElement(value); - if (key === "burstHeatmap") applyBurstHeatmap(); +$(document).ready(() => { + UpdateConfig.subscribeToEvent((eventKey, eventValue) => { + if ( + [ + "difficulty", + "blindMode", + "stopOnError", + "paceCaret", + "minWpm", + "minAcc", + "minBurst", + "confidenceMode", + "layout", + ].includes(eventKey) + ) { + updateModesNotice(); + } + if (eventKey === "flipTestColors") flipColors(eventValue); + if (eventKey === "colorfulMode") colorful(eventValue); + if (eventKey === "highlightMode") updateWordElement(eventValue); + if (eventKey === "burstHeatmap") applyBurstHeatmap(); + }); }); export let currentWordElementIndex = 0;