From ca58c9e6f6be4f82eae510fed38b9c1f6dd62738 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 10 Feb 2022 21:34:28 +0100 Subject: [PATCH] subscribing to config event part of #2462 --- frontend/src/js/config.js | 7 ------- frontend/src/js/test/timer-progress.js | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/frontend/src/js/config.js b/frontend/src/js/config.js index 1137a484b..b61053936 100644 --- a/frontend/src/js/config.js +++ b/frontend/src/js/config.js @@ -1,7 +1,6 @@ import * as DB from "./db"; import * as Sound from "./controllers/sound-controller"; import * as OutOfFocus from "./test/out-of-focus"; -import * as TimerProgress from "./test/timer-progress"; import * as LiveWpm from "./test/live-wpm"; import * as LiveAcc from "./test/live-acc"; import * as LiveBurst from "./test/live-burst"; @@ -680,11 +679,6 @@ export function setShowTimerProgress(timer, nosave) { timer = false; } config.showTimerProgress = timer; - if (config.showTimerProgress && TestLogic.active) { - TimerProgress.show(); - } else { - TimerProgress.hide(); - } if (!nosave) saveToLocalStorage(); dispatchEvent("showTimerProgress", config.showTimerProgress); } @@ -770,7 +764,6 @@ export function setTimerStyle(style, nosave) { style = "mini"; } config.timerStyle = style; - TimerProgress.updateStyle(); if (!nosave) saveToLocalStorage(); dispatchEvent("timerStyle", config.timerStyle); } diff --git a/frontend/src/js/test/timer-progress.js b/frontend/src/js/test/timer-progress.js index c98439ff4..618e49cbe 100644 --- a/frontend/src/js/test/timer-progress.js +++ b/frontend/src/js/test/timer-progress.js @@ -1,4 +1,4 @@ -import Config from "../config"; +import Config, * as UpdateConfig from "../config"; import * as CustomText from "./custom-text"; import * as Misc from "../misc"; import * as TestLogic from "./test-logic"; @@ -189,3 +189,16 @@ export function updateStyle() { show(); }, 125); } + +$(document).ready(() => { + UpdateConfig.subscribeToEvent((eventKey, eventValue) => { + if (eventKey === "showTimerProgress") { + if (eventValue === true && TestLogic.active) { + show(); + } else { + hide(); + } + } + if (eventKey === "timerStyle") updateStyle(); + }); +});