2021-02-02 02:47:05 +08:00
|
|
|
import Storage from '/imports/ui/services/storage/session';
|
|
|
|
import getFromUserSettings from '/imports/ui/services/users-settings';
|
|
|
|
|
2020-12-22 03:47:00 +08:00
|
|
|
const promiseTimeout = (ms, promise) => {
|
|
|
|
const timeout = new Promise((resolve, reject) => {
|
|
|
|
const id = setTimeout(() => {
|
|
|
|
clearTimeout(id);
|
|
|
|
|
|
|
|
const error = {
|
|
|
|
name: 'TimeoutError',
|
|
|
|
message: 'Promise did not return',
|
|
|
|
};
|
|
|
|
|
|
|
|
reject(error);
|
|
|
|
}, ms);
|
|
|
|
});
|
|
|
|
|
|
|
|
return Promise.race([
|
|
|
|
promise,
|
|
|
|
timeout,
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
|
2021-02-02 02:47:05 +08:00
|
|
|
const getSkipVideoPreview = () => {
|
|
|
|
const KURENTO_CONFIG = Meteor.settings.public.kurento;
|
|
|
|
|
|
|
|
const skipVideoPreviewOnFirstJoin = getFromUserSettings(
|
|
|
|
'bbb_skip_video_preview_on_first_join',
|
|
|
|
KURENTO_CONFIG.skipVideoPreviewOnFirstJoin,
|
|
|
|
);
|
|
|
|
const skipVideoPreview = getFromUserSettings(
|
|
|
|
'bbb_skip_video_preview',
|
|
|
|
KURENTO_CONFIG.skipVideoPreview,
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
(Storage.getItem('isFirstJoin') !== false && skipVideoPreviewOnFirstJoin)
|
|
|
|
|| skipVideoPreview
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2018-11-07 07:10:56 +08:00
|
|
|
export default {
|
2020-12-22 03:47:00 +08:00
|
|
|
promiseTimeout,
|
2018-11-07 07:10:56 +08:00
|
|
|
changeWebcam: (deviceId) => {
|
|
|
|
Session.set('WebcamDeviceId', deviceId);
|
|
|
|
},
|
2018-11-17 02:56:39 +08:00
|
|
|
webcamDeviceId: () => Session.get('WebcamDeviceId'),
|
2019-04-09 06:07:26 +08:00
|
|
|
changeProfile: (profileId) => {
|
|
|
|
Session.set('WebcamProfileId', profileId);
|
|
|
|
},
|
2021-02-02 02:47:05 +08:00
|
|
|
getSkipVideoPreview,
|
2018-11-07 07:10:56 +08:00
|
|
|
};
|