subscribing to config event

fixes 1 circular dependency
part of #2462
This commit is contained in:
Miodec 2022-02-10 22:49:21 +01:00
parent 60b04c1f0c
commit bcde1d6a8d
2 changed files with 9 additions and 3 deletions

View file

@ -2,7 +2,6 @@ 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 * as BackgroundFilter from "./elements/custom-background-filter";
import LayoutList from "./test/layouts";
export let localStorageConfig = null;
@ -1240,8 +1239,6 @@ export function setCustomBackgroundSize(value, nosave) {
export function setCustomBackgroundFilter(array, nosave) {
config.customBackgroundFilter = array;
BackgroundFilter.loadConfig(config.customBackgroundFilter);
BackgroundFilter.apply();
if (!nosave) saveToLocalStorage();
dispatchEvent("customBackgroundFilter", config.customBackgroundFilter);
}

View file

@ -122,3 +122,12 @@ $(".section.customBackgroundFilter .save.button").click((e) => {
UpdateConfig.setCustomBackgroundFilter(arr, false);
Notifications.add("Custom background filters saved", 1);
});
$(document).ready(() => {
UpdateConfig.subscribeToEvent((eventKey, eventValue) => {
if (eventKey === "customBackgroundFilter") {
loadConfig(eventValue);
apply();
}
});
});