subscribing to config event

part of #2462
This commit is contained in:
Miodec 2022-02-10 21:37:42 +01:00
parent 51039fdc8d
commit 6af3e5e89e
2 changed files with 8 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 LiveAcc from "./test/live-acc";
import * as LiveBurst from "./test/live-burst";
import * as Funbox from "./test/funbox";
import * as Notifications from "./elements/notifications";
@ -697,11 +696,6 @@ export function setShowLiveAcc(live, nosave) {
live = false;
}
config.showLiveAcc = live;
if (live) {
LiveAcc.show();
} else {
LiveAcc.hide();
}
if (!nosave) saveToLocalStorage();
dispatchEvent("showLiveAcc", config.showLiveAcc);
}
@ -714,7 +708,7 @@ export function setShowLiveBurst(live, nosave) {
if (live) {
LiveBurst.show();
} else {
LiveAcc.hide();
LiveBurst.hide();
}
if (!nosave) saveToLocalStorage();
dispatchEvent("showLiveBurst", config.showLiveBurst);

View file

@ -1,4 +1,4 @@
import Config from "../config";
import Config, * as UpdateConfig from "../config";
import * as TestLogic from "./test-logic";
export function update(acc) {
@ -59,3 +59,9 @@ export function hide() {
}
);
}
$(document).ready(() => {
UpdateConfig.subscribeToEvent((eventKey, eventValue) => {
if (eventKey === "showLiveWpm") eventValue ? show() : hide();
});
});