subscribing to config event

part of #2462
This commit is contained in:
Miodec 2022-02-10 21:34:28 +01:00
parent 90d4fed59e
commit ca58c9e6f6
2 changed files with 14 additions and 8 deletions

View file

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

View file

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