2021-10-08 05:47:39 +02:00
|
|
|
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
|
2020-07-10 23:04:36 +02:00
|
|
|
import isEqual from 'util/deep-equal';
|
|
|
|
|
|
|
|
export function stringifyServerParam(configList) {
|
|
|
|
return configList.reduce((acc, cur) => {
|
|
|
|
acc.push(`${cur[0]}:${cur[1]}`);
|
|
|
|
return acc;
|
|
|
|
}, []);
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getSubsetFromKeysArray = (obj, keys) =>
|
|
|
|
Object.keys(obj)
|
2021-10-08 05:47:39 +02:00
|
|
|
.filter((i) => keys.includes(i))
|
2020-07-10 23:04:36 +02:00
|
|
|
.reduce((acc, key) => {
|
|
|
|
acc[key] = obj[key];
|
|
|
|
return acc;
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
export const shouldSetSetting = (key, val, current) => {
|
|
|
|
switch (key) {
|
|
|
|
case DAEMON_SETTINGS.LBRYUM_SERVERS:
|
|
|
|
return val !== null && Array.isArray(val) && val.length && !isEqual(val, current);
|
|
|
|
default:
|
|
|
|
return !isEqual(val, current);
|
|
|
|
}
|
|
|
|
};
|