mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-03 20:40:48 +08:00
subscribing to config event
fixes 2 circular dependencies part of #2462
This commit is contained in:
parent
bcde1d6a8d
commit
c38c767d1c
2 changed files with 8 additions and 4 deletions
|
@ -1,5 +1,4 @@
|
|||
import * as DB from "./db";
|
||||
import * as Sound from "./controllers/sound-controller";
|
||||
import * as OutOfFocus from "./test/out-of-focus";
|
||||
import * as Notifications from "./elements/notifications";
|
||||
import LayoutList from "./test/layouts";
|
||||
|
@ -222,7 +221,6 @@ export function setPlaySoundOnClick(val, nosave) {
|
|||
val = "off";
|
||||
}
|
||||
config.playSoundOnClick = val;
|
||||
if (config.playSoundOnClick !== "off") Sound.init();
|
||||
if (!nosave) saveToLocalStorage();
|
||||
dispatchEvent("playSoundOnClick", config.playSoundOnClick);
|
||||
}
|
||||
|
@ -232,7 +230,6 @@ export function setSoundVolume(val, nosave) {
|
|||
val = "1.0";
|
||||
}
|
||||
config.soundVolume = val;
|
||||
Sound.setVolume(val);
|
||||
if (!nosave) saveToLocalStorage();
|
||||
dispatchEvent("soundVolume", config.soundVolume);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import Config from "../config";
|
||||
import Config, * as UpdateConfig from "../config";
|
||||
import Howler, { Howl } from "howler";
|
||||
|
||||
let errorSound = null;
|
||||
|
@ -248,3 +248,10 @@ export function playError() {
|
|||
export function setVolume(val) {
|
||||
Howler.Howler.volume(val);
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
UpdateConfig.subscribeToEvent((eventKey, eventValue) => {
|
||||
if (eventKey === "playSoundOnClick" && eventValue !== "off") init();
|
||||
if (eventKey === "soundVolume") setVolume(eventValue);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue