2017-12-11 19:01:15 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const socket = require("../socket");
|
|
|
|
const options = require("../options");
|
2019-11-03 18:05:19 +00:00
|
|
|
const store = require("../store").default;
|
2017-12-11 19:01:15 +00:00
|
|
|
|
|
|
|
function evaluateSetting(name, value) {
|
2019-07-17 09:33:59 +00:00
|
|
|
if (
|
2019-11-03 18:05:19 +00:00
|
|
|
store.state.settings.syncSettings &&
|
|
|
|
store.state.settings[name] !== value &&
|
2019-07-17 09:33:59 +00:00
|
|
|
!options.noSync.includes(name)
|
|
|
|
) {
|
2017-12-11 19:01:15 +00:00
|
|
|
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) {
|
2018-03-30 07:32:20 +00:00
|
|
|
options.syncAllSettings();
|
2017-12-11 19:01:15 +00:00
|
|
|
} else {
|
|
|
|
for (const name in settings) {
|
|
|
|
evaluateSetting(name, settings[name]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|