bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/settings/service.js
2019-05-29 11:51:45 -04:00

37 lines
785 B
JavaScript

import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth';
import Settings from '/imports/ui/services/settings';
import { notify } from '/imports/ui/services/notification';
const getUserRoles = () => {
const user = Users.findOne({
userId: Auth.userID,
});
return user.role;
};
const updateSettings = (obj, msg) => {
Object.keys(obj).forEach(k => (Settings[k] = obj[k]));
Settings.save();
if (msg) {
// prevents React state update on unmounted component
setTimeout(() => {
notify(
msg,
'info',
'settings',
);
}, 0);
}
};
const getAvailableLocales = () => fetch('/html5client/locales').then(locales => locales.json());
export {
getUserRoles,
updateSettings,
getAvailableLocales,
};