bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/settings/service.js
Ramón Souza 7514066fc3
fix: Client can't load in certain cases (#20336)
* move settings

* remove meteor cache files
2024-05-29 09:26:11 -04:00

62 lines
1.6 KiB
JavaScript

import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth';
import { getSettingsSingletonInstance } from '/imports/ui/services/settings';
import { notify } from '/imports/ui/services/notification';
import GuestService from '/imports/ui/components/waiting-users/service';
import intlHolder from '../../core/singletons/intlHolder';
const getUserRoles = () => {
const user = Users.findOne({
userId: Auth.userID,
});
return user?.role;
};
const isPresenter = () => {
const user = Users.findOne({
userId: Auth.userID,
});
return user?.presenter;
};
const showGuestNotification = () => {
const guestPolicy = GuestService.getGuestPolicy();
// Guest notification only makes sense when guest
// entrance is being controlled by moderators
return guestPolicy === 'ASK_MODERATOR';
};
const isKeepPushingLayoutEnabled = () => window.meetingClientSettings.public.layout.showPushLayoutToggle;
const updateSettings = (obj, msgDescriptor, mutation) => {
const Settings = getSettingsSingletonInstance();
Object.keys(obj).forEach(k => (Settings[k] = obj[k]));
Settings.save(mutation);
if (msgDescriptor) {
// prevents React state update on unmounted component
setTimeout(() => {
const intl = intlHolder.getIntl();
notify(
intl.formatMessage(msgDescriptor),
'info',
'settings',
);
}, 0);
}
};
const getAvailableLocales = () => fetch('./locale-list').then(locales => locales.json());
export {
getUserRoles,
isPresenter,
showGuestNotification,
updateSettings,
isKeepPushingLayoutEnabled,
getAvailableLocales,
};