hardlounge/client/js/socket-events/setting.js
Pavel Djundik c26de4cf6a Move options to vuex
Co-Authored-By: Tim Miller-Williams <timmw@users.noreply.github.com>
2019-11-25 20:12:56 +02:00

34 lines
789 B
JavaScript

"use strict";
const socket = require("../socket");
const options = require("../options");
const store = require("../store").default;
function evaluateSetting(name, value) {
if (
store.state.settings.syncSettings &&
store.state.settings[name] !== value &&
!options.noSync.includes(name)
) {
options.processSetting(name, value, true);
} else if (options.alwaysSync.includes(name)) {
options.processSetting(name, value, true);
}
}
socket.on("setting:new", function(data) {
const name = data.name;
const value = data.value;
evaluateSetting(name, value);
});
socket.on("setting:all", function(settings) {
if (Object.keys(settings).length === 0) {
options.syncAllSettings();
} else {
for (const name in settings) {
evaluateSetting(name, settings[name]);
}
}
});