2022-05-30 22:02:08 +00:00
|
|
|
import { defaultSettings } from '../constants';
|
|
|
|
|
|
|
|
export function parseSettings(settings: any) {
|
|
|
|
return settings.reduce((ret: any, item: any) => {
|
|
|
|
// @ts-ignore
|
|
|
|
ret[item._id] = defaultSettings[item._id] && item[defaultSettings[item._id].type];
|
|
|
|
if (item._id === 'Hide_System_Messages') {
|
|
|
|
ret[item._id] = ret[item._id].reduce(
|
|
|
|
(array: any, value: any) => [...array, ...(value === 'mute_unmute' ? ['user-muted', 'user-unmuted'] : [value])],
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return ret;
|
2022-08-12 12:35:55 +00:00
|
|
|
}, {});
|
2022-05-30 22:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function _prepareSettings(settings: any) {
|
|
|
|
return settings.map((setting: any) => {
|
|
|
|
// @ts-ignore
|
|
|
|
setting[defaultSettings[setting._id].type] = setting.value;
|
|
|
|
return setting;
|
|
|
|
});
|
|
|
|
}
|